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

Related posts:

  1. How to download directory using ftp unfortunately using the bare-bone command line shell ftp which comes...
  2. cp to copy from Current to previous directory It took me a couple of minutes to figure out...
  3. How is Linux Different than Solaris Differences between Linux and Solaris Linux is also just a...
  4. How to delete protected vista files from XP by booting to windows XP I was trying to free...
  5. FTP Files from Shell Script Here is a sample bash or shell script that will...
  6. Search and replace text in all files in Sub directories if you want to Search for a particular string or...

Trackback

only 1 comment untill now

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

Add your comment now