Last active
October 14, 2018 13:49
-
-
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
This file contains 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 | |
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