Count file in Linux

Count file in a directory:

ls -l |grep "^-"|wc -l

Count file in a directory, include subdirectories:

ls -lR|grep "^-"|wc -l

Count subdirectory in a directory:

ls -l|grep "^d"|wc -l

Count subdirectory in a directory, include subdirectories:

ls -lR|grep "^d"|wc -l

Leave a Reply

Your email address will not be published. Required fields are marked *