|
How to Count Files in a folder |
|
|
|
# ls | wc -l or # echo * | wc -w
Echo is a built in command in Linux. wc - word count -l - Count the lines -w count the words When using echo * the result comes out as a single line with file names, so we need to use the -w option of wc. When using ls the result comes out as a series of lines, one line per file, so we need to use the -l. This makes some assumptions about the default configuration of ls.
|