Results 1 to 3 of 3
The following script seems to work well:
for f in `ls -R | grep ":" | sed "s/://"`; do echo $f `ls $f | wc -l`; done
The only limitation ...
- 05-14-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 1
List file count in subdirectories - one line shell script
The following script seems to work well:
for f in `ls -R | grep ":" | sed "s/://"`; do echo $f `ls $f | wc -l`; done
The only limitation is that it will report errors for files containing a colon ":".
David Rodecker
Getting Local Businesses Online
localsplash.com
- 05-14-2009 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
this is an old thread.
issues with your method
1) for loop with ls -R breaks on files with spaces in their names
2) why use grep ":" and sed together , when sed is supposed to find ":" also? therefore grep is redundant
3) echo $f `ls $f | wc -l` <--- what if $f is a file instead of a directory?
- 05-16-2009 #3Just Joined!
- Join Date
- May 2009
- Posts
- 6
better way is : find "directory name" -type f |wc -l


Reply With Quote
