Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add .deja-dup-ignore file to all subdirectories matching a pattern
# This will only add it to the first instance/depth of the matching ignoreFolder (ie. it won't add it to the sub-dependencies of any node_modules folder
find $startPath -mindepth 1 -maxdepth 5 -name "$ignoreFolder" -type d -not -regex ".*$ignoreFolder.*$ignoreFolder.*" | while read fname; do
echo "" > "$fname/.deja-dup-ignore"
echo "$fname/.deja-dup-ignore created."
Copy link

With this at the beginning of the script, you don't need hardcoded paths ;-)
You can then use script like this:

$ -s /home/rw3iss/Sites -i node_modules


while getopts s:i: flag
    case "${flag}" in
        s) startPath=${OPTARG};;
        i) ignoreFolder=${OPTARG};;

Copy link

rw3iss commented Jun 1, 2021

Ah cool! I am not a bash expert and only dabble. I also don't use this script anymore - moved from DejaDup to Duplicity so I could manage things more manually. However, you just taught me how to parse options. Thank you! May the benevolent bash gods shine their favor upon you :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment