So I'm scanning through a directory and want to test if each element of the directory is a directory:
FILES=$PWD/*
for f in $FILES
do
if [ $f is a directory ]; then #Correct conditional needed here
echo "Dir: $f"
fi
done
What method/function do I use to test if $f is a directory?
Use -d
to check:
if [ -d "$f" ]; then
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With