Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 01-27-2005, 09:12 AM   #1
LQ Newbie
Registered: Jul 2004
Location: Waregem, Belgium
Distribution: Slackware 10.2
Posts: 27

Rep: Reputation: 15
du or wc and file names with spaces


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,
Old 01-27-2005, 09:47 AM   #2
Registered: Jan 2005
Location: Perth, Western Australia
Distribution: Slackware 10.2, LFS6.1.1
Posts: 41

Rep: Reputation: 15
Ummm im not sure if i understand you correctly but

wc *.c
du -c *.c
Old 01-27-2005, 11:43 AM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Diskspace: not using du, though...
find -iname "*.[ch]" -exec ls -l {} \; | awk '{bytes += $5 ; files += 1  }; END { print "Bytes total is", bytes ," in ", files ," files"} '
Lines would be similar ...
find -iname "*.[ch]" -exec wc -l {} \; | awk '{lines += $1 ; files += 1  }; END { print "Lines total is", lines ," in ", files ," files"} '



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to handle file names with spaces in them bahadur Programming 14 04-04-2005 12:04 PM
how to handle file names with spaces in them bahadur Programming 3 03-23-2005 05:15 AM
Spaces in file names JohnKFT Slackware 3 11-09-2004 03:44 PM
Bash crashes ? File names with () and spaces Danodare Slackware 1 02-27-2004 02:50 PM
File/Direcory Names with Spaces ar1 Linux - General 3 01-15-2004 10:41 AM

All times are GMT -5. The time now is 03:08 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration