I am trying to check if an argument is a directory or a file. I want to put a / after each directory name and a * after every executable file. I know ls uses -F to get this information but I can’t figure this out in my script.
Here is my code:
echo -n "Please enter Directory name you wish to search: "
read dir
for filename in "/home/me/Desktop/$dir"/*
do
if (-F $filename)
then
echo $filename
fi
done
[ -f "$filename" ]is true for files,[ -d "$dirname" ]is true for directories.