Comments on How to get number of files in directory
Parent
Post
+5
−0
Populate an array of the file names and then print how many entries are in the array:
$ files=( * )
$ echo "${#files[@]}"
124
That will work correctly even if your file names contain newlines, unlike anything piped to wc -l
.
0 comment threads