|
|
Counting files in a directory from the terminal
I know this topic is about 5 years old but what ever if someone finds it looking for this info (like I did) it might still help.
If you are trying to count the # of lines of files in a dir you can use
Note that I made sure I didn't include "data" files, in this case I knew they were all jpg but it might be easier to do the opposite and include only certain extensions. ---
Counting files in a directory from the terminal
That's broken in several ways (unnecessary cat; includes directories; doesn't handle filenames with embedded spaces; matched .jpg anywhere in the filename). Try something like this:
find . -not -type d | egrep -v '\.jpg$' | wc -lThe "-not -type d" excludes directories but would find symlinks and other non-regular files; change it to "-type f" to only find regular files. There should be a single backslash before the dot in the .jpg string for egrep; I always seem to get that quoting wrong here because the preview doesn't match the post. |
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.07 seconds |
|