If I have a list of numbers in a file, how do I add the numbers together? Do I use grep???
|
grep will not do you any good. grep can only find text in files based on a search criteria.
This script will work. #!/bin/sh TOTAL=0 for NUM in `cat filename`; do TOTAL=`expr $NUM + $TOTAL` done echo $TOTAL |
All times are GMT -5. The time now is 08:22 PM. |