0

I need to list the number of files (hidden AND visible) on a hard drive, including those in subfolders. Looking for a simple command for this please?

This is separate from my previous question where I wanted a list of the files themselves.

Also, is there a way to only list the number of files not the folders, or are they all included by default?

Cheers

Ravexina
  • 55,668
  • 25
  • 164
  • 183
SD_NZ
  • 91

1 Answers1

3
find Downloads/ -type f | wc -l

Returns the number of all files (Including hidden files0 withing Downloads directory and all it's sub-directories.

Also for a partition you can use something like df --inodes /home. Read this answer for more information.

Ravexina
  • 55,668
  • 25
  • 164
  • 183
  • Some people say find Downloads/ -type f -printf x | wc -c is faster and more reliable as it just prints an x for every found file and then counts the xes. – PerlDuck Sep 01 '18 at 13:18