[lug] Some help with bash, please

Jeff Schroeder jeff at zingstudios.com
Wed Feb 20 09:29:51 MST 2008


Ken wrote:

> /tmp/orders is a file that has a filename, one per line
>
> Each /dgorder/$file has a number of records in it and I'm trying to
> count the total number of records in all the files.

If I understand you correctly, you have a list of files in /tmp/orders, 
and you want to count the total lines in those files.

If so, it seems like you could do it like this:

# wc -l $(cat /tmp/orders) | tail -1

This assumes the filenames in /tmp/orders are full paths, or in the 
current directory.  You're just running 'wc' on all of the files, and 
when you do that it prints a final line with the total it counted.  
Using 'tail' keeps just that line.

HTH,
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20080220/9a74c3b6/attachment.pgp>


More information about the LUG mailing list