[ale] Simple script question

Charles Shapiro cshapiro at nubridges.com
Tue Mar 16 13:58:14 EST 2004


Of course, if you already know the find(1) man page, then:

find . -type f -exec wc -l {} \; 

Or, to get a _total_ number of lines,

find . -type f -exec cat {} \; | wc -l

Will work. You can often avoid using xargs(1) with shell looping
constructs, and it can be a good idear because xargs(1) will arbitrarily
group the filenames and pass them in wads to your program. In this case
that is ok, but I've seen places where this becomes an annoyance.

-- CHS

On Tue, 2004-03-16 at 12:57, Bridges, Doug wrote:
> And we have a winner.
> 
> That worked like a charm.  Xargs seems to be one the most powerful tools in Linux.
> 
> Doug
> 
> -----Original Message-----
> From: ale-bounces at ale.org [mailto:ale-bounces at ale.org]On Behalf Of Mike
> Murphy
> Sent: Tuesday, March 16, 2004 12:40 PM
> To: Atlanta Linux Enthusiasts
> Subject: Re: [ale] Simple script question
> 
> 
> find . -type f |xargs cat |wc -l ??
> 
> seems to work on the absurdly small test directory I created.
> 
> Mke
> 
> 
> Bridges, Doug wrote:
> > I am trying to write a simple script that will recursively give me a line count of all of the files in a directory.  Here is the command I am trying:
> > 
> > wc -l < cat `find . -type f -name "*"`
> > 
> > When I do this, I get:
> > bash: cat: No such file or directory
> > 
> > 
> > I suspect that some of the files might be too deep, or not exist.  

> Also, I am doing this on cygwin, I don't know if this is some 

> windows bug creeping in.
> > 
> > Doug
> > 
> > 
> > 
> > _______________________________________________________
> > 
> > NOTICE:  This e-mail message and all attachments transmitted with it 
> > may contain legally privileged and confidential information intended 
> > solely for the use of the addressee.  If the reader of this message is not 
> > the intended recipient, you are hereby notified that any reading, 
> > dissemination, distribution, copying, or other use of this message or its 
> > attachments is strictly prohibited.  If you have received this message in 
> > error, please notify the sender immediately by telephone 
> > (404-881-7000) or by electronic mail (postmaster at alston.com), and 
> > delete this message and all copies and backups thereof.  Thank you.
> > _______________________________________________________
> > 
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://www.ale.org/mailman/listinfo/ale



More information about the Ale mailing list