Skip to content

Instantly share code, notes, and snippets.

@Yank-225
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save Yank-225/775efdfd33c28df0f4e9 to your computer and use it in GitHub Desktop.

Select an option

Save Yank-225/775efdfd33c28df0f4e9 to your computer and use it in GitHub Desktop.
#!/bin/bash
#traversal rules in .gitignore file
while read LINE
do
#ignore empty line
if [ -n "$LINE" ];then
#line include "#" is comment
if [[ $LINE != *"#"* ]]
then
# wildcard * need to find
if [[ $LINE == *"*"* ]]
then
files=($(find -name $LINE ))
#file lists
for file in "${files[@]}"; do
cmd="dropbox exclude add $file"
eval "$cmd"
done
else
#specified file can't use command find
#there may be file with samename
cmd="dropbox exclude add $LINE"
eval "$cmd"
fi
fi
fi
done < .gitignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment