Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Integralist/6d9444532e5b500942ebc8759c278d2f to your computer and use it in GitHub Desktop.
Save Integralist/6d9444532e5b500942ebc8759c278d2f to your computer and use it in GitHub Desktop.
[Bash loop files in a directory and check their types] #bash #directory #file #search
#!/bin/bash
project=~/foo
service=bar
ignore=("cmd" "lib" "scripts")
for filename in $project/$service/*; do
if [[ -d $filename ]]; then
echo "$filename is a directory"
f=$(basename "$filename")
if [[ ! "${ignore[@]}" =~ $f ]]; then
echo "$filename ($f) is a directory we want to symlink"
fi
fi
done
###
for filename in ~/foo/*; do
echo "file name is: $filename";
if [[ -d $filename ]]; then
echo "$filename is a directory"
elif [[ -f $filename ]]; then
echo "$filename is a file"
else
echo "$filename is not valid"
fi
# for ((i=0; i<=3; i++)); do
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment