Created
September 23, 2017 21:30
-
-
Save binki/68955396d8247ee379211b59223b57b7 to your computer and use it in GitHub Desktop.
to skip a named subdir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./skipDir.sh | |
/a/b/c is permitted | |
/e/f/blah is banned |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bannedDirs=( | |
bin | |
blah | |
) | |
for actualDir in /a/b/c '/e/f/blah'; do | |
isBanned= | |
for bannedDir in "${bannedDirs[@]}"; do | |
[[ "${actualDir##*/}" = "${bannedDir}" ]] && isBanned=1 | |
done | |
if [[ "${isBanned}" ]]; then | |
echo "${actualDir} is banned" | |
else | |
echo "${actualDir} is permitted" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment