M BUZZ CRAZE NEWS
// news

What does the command "find ~/folder-name -type f | wc -l" do?

By David Jones

The context Also, could you take a look at the context that suggested by @VolkerSiegel in her/him comment here.

1

2 Answers

Let's split it into parts: find ~/folder-name -type f | wc -l

  1. find is a program for, well, finding files and folders:
    • ~/folder-name is the directory in which find will try to find files/folders
    • -type f tells find to look only for files (and not directories, special files, etc.)
  2. wc is a program to count characters, words, and lines in some text (a file, or the input that you give it).
    • -l tells it to only count lines.
  3. | sends the output of find to wc.

All told, it counts the total number of files in the directory ~/folder-name, and all its sub-directories. In your case you have 1305252 files, not counting links, directories and other special files. That's a pretty big number (IIRC a MATLAB installation has around 500000 files, less than half that, and still takes forever to delete). That would go a long way in explaining the long times. The sheer amount of time find took should be hint.

As another reference point, my own home directory, with a total size of 361GB spanning a few partitions has only 282747 files (one fourth of your number!).

It counts (wc -l) the number of regular files (-type f) that are found - recursively - in the directory ~/folder-name.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy