|
|
File Count using Terminal
You can also use the terminal and the recursive flag from ls and then piping that output to wc.
File Count using Terminal
Hi,
"ls -R | wc -l" will not work because one, the contents of each directory are printed multiple entries per line, and two, ls includes information and blank lines that leads to an incorrect total. The closest I can get with a simple ls variant is "ls -1R | grep -v ^$ | grep -v :$ | wc -l", but this only works if none of the files or subdirectories end with a colon.
- Avi
Re: File Count using Terminal
Sorry, trivial examples disprove that. The default style for ls is one-entry-per-line when output isn't sent to the terminal and you can force that using the -1 (minus one) option; read the man page. Also look at -A, noting the difference between it and -a.
A fast way to count files is by utilizing the locate command. Simple example to count one user's files: locate /Users/me/ | wc -l See my comment in Finding files with 'locate' about locate.db permission issues which affect results of this. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.12 seconds |
|