Skip to content

Commit fe2c6a9

Browse files
author
Denevell - Mainly a mobile developer
committed
Create unix-count-files-in-directory.md
1 parent 2db2a98 commit fe2c6a9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

unix-count-files-in-directory.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Title: Count the files in a directory
2+
Tags: unix
3+
4+
ls -1 | wc -l
5+
6+
That lists the files (-1 doesn't include the TOTAL line) and pipes the output for word count, that with the -l parameter counts of lines.
7+
8+
This includes sub directories, however. This:
9+
10+
find . -maxdepath 1 -t f | wc -l
11+
12+
doesn't (only searches files in a maximum folder depth of one), but it does include hidden files, however.

0 commit comments

Comments
 (0)