List all files only in shell script

February 3, 2010 at 22:58:58
Specs: Windows XP
Hi experts,

I need help in shell script, to list all the files names and files count in a folder without taking count the subfolder

i used this; but its included all the subfolders

ls | wc -l


Hope someone can help me


See More: List all files only in shell script

Report •


#1
February 3, 2010 at 23:38:03
ya just want the count, this might:
ls -FA1 | grep -v "/$" | wc -l

Report •

#2
February 4, 2010 at 03:31:40
Thanks nbrane,
i did with some way that i can understand and of cause its easy

cd /cygdrive/c/folderA
count=0
one=1
for FILES in *.*
do
echo $FILES >>/cygdrive/c/folderB/Logfile.log
count=`expr $count + 1`
done
echo $count >>/cygdrive/c/folderB/Logfile.log

its good for beginners
hehehe


Report •

#3
February 4, 2010 at 08:01:29
> ya just want the count, this might:
> ls -FA1 | grep -v "/$" | wc -l
>

Something like that I assume as well ... Celvin, did you check all of the parameters of LS ?


Report •

Related Solutions

#4
February 4, 2010 at 16:06:38
it might be counting directories also, did you check that? (because *.* will include them i think). Also, it might be skipping files with no dot (.) in them.

Report •


Ask Question