[Linux] How to check how many folders and subdirectories there are under Linux

ls -l | wc -l

That is, the number of files can be obtained by processing the result of ls through the pipeline for wc -l. In fact, this number includes the number of folders.

wc means word count, -l counts the number of lines, so it is the number of files

1. Command format:

wc [options] file...

2. Command function:

Count the number of bytes, words, and lines in the specified file, and display and output the statistical results. This command counts the number of bytes, words, and lines in the specified file. If no file name is given, it is read from standard input. wc also gives the presidential count of the specified file.

3. Command parameters:

-c counts the number of bytes.

-l count the number of rows.

-m counts the number of characters. This flag cannot be used with the -c flag.

-w counts the number of words. A word is defined as a string of characters separated by blanks, tabs, or newlines.

-L Print the length of the longest line.

-help display help information

--version display version information



Guess you like

Origin blog.csdn.net/michellechouu/article/details/50764919