If a directory has a large number of files on your Linux, UNIX or Solaris system and you are puzzled about their count then it is very easy

Just do

ls –l | wc –l

ls will list the files and wc –l will count the number of lines

If you want to count some specific type of file then you can use ls with the * operator to list only the desired type and then feed it to wc

suppose you want to count the number of .tmp files
You can do

ls -l *.tmp | wc -l


only 1 comment untill now

  1. What if I also want to count the files in Sub directories?

Add your comment now