Skip to content

Instantly share code, notes, and snippets.

@binki
Created September 23, 2017 21:30
Show Gist options
  • Save binki/68955396d8247ee379211b59223b57b7 to your computer and use it in GitHub Desktop.
Save binki/68955396d8247ee379211b59223b57b7 to your computer and use it in GitHub Desktop.
to skip a named subdir
$ ./skipDir.sh
/a/b/c is permitted
/e/f/blah is banned
#!/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