When not viewing hidden files
ll | wc -l
- 1
When hidden files are included,
It cannot be used directly ls -al |wc -l
because executing the ls -al command will not only display all files, but also the current folder and parent folder,
so ls -al|wc -l
you will get the following results.
This is inaccurate because I did not hide the files. The results should be the ll |wc -l
same.
So, we have to subtract 2 from the final result. You can use the following command
expr $(ls -al|wc -l) - 2
- 1