[wplug] Handling spaces in file names

Embery, Nathan Nathan.Embery at crowncastle.com
Fri Nov 19 15:18:34 EST 2004


OK, I'm convinced wc is brain dead. For a sum total off all lines of code
instead of a file by file break down, try this:

 find . -name '*java' | xargs -i{} cat {} | awk '{ n++} END {print n}'


Ugly no doubt. 

-----Original Message-----
From: wplug-bounces+nathan.embery=crowncastle.com at wplug.org
[mailto:wplug-bounces+nathan.embery=crowncastle.com at wplug.org] On Behalf Of
Embery, Nathan
Sent: Friday, November 19, 2004 3:05 PM
To: 'farra at apache.org'; 'General user list'
Subject: RE: [wplug] Handling spaces in file names

Maybe something like this?

  find . -name '*java' | xargs -i{} wc {} 

Nate

-----Original Message-----
From: wplug-bounces+nathan.embery=crowncastle.com at wplug.org
[mailto:wplug-bounces+nathan.embery=crowncastle.com at wplug.org] On Behalf Of
J Aaron Farr
Sent: Friday, November 19, 2004 2:24 PM
To: wplug at wplug.org
Subject: [wplug] Handling spaces in file names

Hello all.

Simple UNIX scripting question:

I want to do this:

  wc `find . -name *.java`

on a large repository to get total number of lines of code.  But some of
the files or directories have spaces which 'wc' doesn't like.  So, do I
have to write up a script to do this or is there some way I can get 'find'
to print the file names with the spaces escaped?  (ie- "My\ Documents"
instead of "My Documents")

Thanks for any suggestions.
jaaron
_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug
_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug


More information about the wplug mailing list