1

In this post: Count files and directories using shell script, DogBane gave this reply on December 5, 2012:

FILECOUNT="$(find . -type f -maxdepth 1 -printf x | wc -c)"
DIRCOUNT="$(find . -type d -maxdepth 1 -printf x | wc -c)"

Can anyone please tell me what the x after -printf means or is used for?

Thank you.

Community
  • 1
  • 1
  • It is _another_ way to say: `FILECOUNT="$(find . -type f -maxdepth 1 | wc -l)"` ... if that helps ... – devnull Feb 09 '14 at 15:38

1 Answers1

2

-printf x will simply print one x for each match, with no new-line or anything else (esp. not the filename).

These find commands just print one character for each file (or directory) found, and then count the number of characters (wc -c).

Mat
  • 202,337
  • 40
  • 393
  • 406