1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three margin testing

Tuesday, June 2, 2009

How to Find the Total Number of Files in a Linux Folder

To count recursively:

for t in files links directories; do echo `find . -type ${t:0:1} | wc -l` $t; done 2> /dev/null

If you don't want to recurse directories (only count files in the current dir):

for t in files links directories; do echo `find . -maxdepth 1 -type ${t:0:1} | wc -l` $t; done 2> /dev/null

Result:

655 files
6 links
213 directories

Note: Directory count begins at 1 because . is counted as a directory.

Featured Post

Windows和Ubuntu双系统完全独立的安装方法

http://www.ubuntuhome.com/windows-and-ubuntu-install.html  | Ubuntu Home Posted by Snow on 2012/06/25 安装Windows和Ubuntu双系统时,很多人喜欢先安装windows,然...