LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   du or wc and file names with spaces (https://www.linuxquestions.org/questions/slackware-14/du-or-wc-and-file-names-with-spaces-282859/)

bramadams 01-27-2005 09:12 AM

du or wc and file names with spaces
 
Hi,

This issue has been giving me much trouble. The current directory points to the root of a CD with directories containing spaces in their names. How can you count the total number of lines in all *.c-files (recursively) using wc? An equivalent problem: How to determine the total disk space occupied by those files using du?

Eventually I could solve it somehow using grep, but there has to be a solution using wc and du (adjusting $IFS?).

Your suggestions are welcome,

roninja 01-27-2005 09:47 AM

Ummm im not sure if i understand you correctly but

wc *.c
du -c *.c

Tinkster 01-27-2005 11:43 AM

Diskspace: not using du, though...
Code:

find -iname "*.[ch]" -exec ls -l {} \; | awk '{bytes += $5 ; files += 1  }; END { print "Bytes total is", bytes ," in ", files ," files"} '
Lines would be similar ...
Code:

find -iname "*.[ch]" -exec wc -l {} \; | awk '{lines += $1 ; files += 1  }; END { print "Lines total is", lines ," in ", files ," files"} '


Cheers,
Tink


All times are GMT -5. The time now is 08:51 PM.