LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-27-2005, 09:12 AM   #1
bramadams
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


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,
 
Old 01-27-2005, 09:47 AM   #2
roninja
Member
 
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
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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

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