[lug] Some help with bash, please
Kenneth D Weinert
kenw at quarter-flash.com
Wed Feb 20 09:17:28 MST 2008
OK, I'm feeling really dumb right now as this just isn't working for me.
Here's the script I'm running:
#!/bin/bash
declare -xi total=0
declare -xi count
cat /tmp/orders | while read file;do
wc -l /dgorder/$file;
done | while read count file;do
total=$((total + count))
done
echo "Number of Orders: $(wc -l /tmp/orders | tr -s ' '|cut -d' ' -f2)"
echo "Total Documents: $total"
/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.
I think the double loop is what's killing me as the $total variable
*always* ends up being zero.
Any thoughts, hints, pointers, other scripting languages are more than
welcome. Since all the files are in the same directory I can fix the
main input file to have complete paths instead of just file names if
that helps.
Thanks - and I'm sure that as soon as I see a response or two I'll do
the old V8 slap to the forehead and wonder how I could be so dumb.
--
Ken Weinert
http://quarter-flash.com
Please avoid sending me Word or PowerPoint attachments
http://www.gnu.org/philosophy/no-word-attachments.html
-------------- 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/c8f74528/attachment.pgp>
More information about the LUG
mailing list