Check if the argument is a file or directory

I am trying to check if an argument is a directory or a file. I want to put / after each directory name and * after each executable. I know ls uses -F to get this information, but I cannot figure it 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
+5
source share
1 answer

[ -f "$filename" ]true for files [ -d "$dirname" ]- true for directories.

+9
source

All Articles