Click to See Complete Forum and Search --> : Get number of files in a dir


jdvilla
07-08-2004, 01:11 AM
How can I get the number of files in a directory?

hlrguy
07-08-2004, 01:36 AM
ls |wc -l
ls -d |wc -l

I was surprised that ls didn't have an 'exclude directories' option, so two steps. That is wc - 'el', not 'one'.

hlrguy

jdvilla
07-08-2004, 01:51 AM
thanks.

hlrguy
07-08-2004, 02:05 AM
Oops, forgot the important step. Subtract the smaller number (the number of subdirectiries) from the larger number, (the number of files + subdirectories).

Glad to help.

hlrguy