For files in directory, ignoring folders
As in my previous answer you really want to use find
. What you're trying to do on 7-10 of lines scripting can just be done with this:
find /home/user -type f -printf "%f\n"
You can use -d
operator to check whether $filename
refers to a directory:
for filename in /home/user/*do if [ ! -d "${filename}" ] then echo $filename fidone;
See test manpage for details and other available operators.
You can also use the find command:
find /home/user -not -type d -maxdepth 1