Welcome to the most active Linux Forum on the web.
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, 10: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, 10: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, 12:43 PM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,047
Blog Entries: 11

Rep: Reputation: 907Reputation: 907Reputation: 907Reputation: 907Reputation: 907Reputation: 907Reputation: 907Reputation: 907
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 01:04 PM
how to handle file names with spaces in them bahadur Programming 3 03-23-2005 06:15 AM
Spaces in file names JohnKFT Slackware 3 11-09-2004 04:44 PM
Bash crashes ? File names with () and spaces Danodare Slackware 1 02-27-2004 03:50 PM
File/Direcory Names with Spaces ar1 Linux - General 3 01-15-2004 11:41 AM

All times are GMT -5. The time now is 07:21 PM.

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