How to Count Files in the Current Directory on Linux

1. Count the number of files in the current directory
Code:
 
ls -l |grep "^-"|wc -l
 
2. Count the number of directories in the current directory
Code:
 
ls -l |grep "^d"|wc -l
 
 
3. Count the number of files in the current directory, including those in subdirectories
Code:
 
ls -lR|grep "^-"|wc -l
 
 
4. Count the number of directories in the current directory, including those in subdirectories
Code:
 
ls -lR|grep "^d"|wc -l

Leave a Comment

Your email address will not be published.