centos view the number of files in the folder

When not viewing hidden files

ll | wc -l
  • 1

Insert picture description here

When hidden files are included,

It cannot be used directly ls -al |wc -lbecause executing the ls -al command will not only display all files, but also the current folder and parent folder,
Insert picture description here
so ls -al|wc -lyou will get the following results.
Insert picture description here
This is inaccurate because I did not hide the files. The results should be the ll |wc -lsame.

So, we have to subtract 2 from the final result. You can use the following command

 expr $(ls -al|wc -l) - 2
  • 1

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42533216/article/details/114025426