Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- total="0"
- count="0"
- #FILE="$1" This is the easier way
- for FILE in $*
- do
- # Start processing all processable files
- while read line
- do
- if [[ "$line" =~ ^Total ]];
- then
- tmp=$(echo $line | cut -d':' -f2)
- count=$(expr $count + 1)
- total=$(expr $total + $tmp)
- fi
- done < $FILE
- done
- echo "The Total Is: $total"
- echo "$FILE"
- while [ $1 != "" ]
- do ....
- done
- while [ "$1" != "" ]; do
- # Code here
- # Next argument
- shift
- done
- grep '^Total:' "$@" |
- cut -d: -f2 |
- awk '{sum += $1}
- END { print sum }'
- grep "^Total:" "$@" |
- awk -F: '{sum += $2}
- END { print sum }'
- awk -F: '$1 ~ /^Total/ { sum += $2 }
- END { print sum }' "$@"
- perl -na -F: -e '$sum += $F[1] if m/^Total:/; END { print $sum; }' "$@"
- while [ $# -gt 0 ]
- do
- ...process $1...
- shift
- done
- #!/bin/sh
- process() {
- echo "doing something with $1"
- }
- for i in "$@" # Note use of "$@" to not break on filenames with whitespace
- do
- process "$i"
- done
- while [ "$1" != "" ]; do
- # Code here
- # Next argument
- shift
- done
Add Comment
Please, Sign In to add comment