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
  • 54,268
  • 25
  • 157
  • 179
SD_NZ
  • 91
  • 1
  • 5
  • You already asked the same question before! [File list command line (hidden and subfolders)](https://askubuntu.com/questions/1028197/file-list-command-line-hidden-and-subfolders) – αғsнιη Apr 29 '18 at 11:44
  • 1
    I wanted just the number of files, not a list of the files themselves – SD_NZ Apr 29 '18 at 12:03
  • I suggest to use `tree --du -aih` which will list all files and directories and shows their corresponding sizes as well as total counts at the end then. – αғsнιη Apr 29 '18 at 12:47

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
  • 54,268
  • 25
  • 157
  • 179
  • 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 `x`es. – PerlDuck Sep 01 '18 at 13:18