How to count the number of files in a directory

Non recursive

find targetdir -type f -maxdepth 1 | wc -l 

Recursive

find targetdir -type f | wc -l 

Recursive and follow symlink

find targetdir -type f -follow | wc -l 

Published 8th Feb 2011 // #debian #tips




comments powered by Disqus