Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- declare -i result=0
- declare -i i=0
- re='^[0-9]+$'
- while read line
- do
- if ! [[ $line =~ $re ]] ; then
- echo "error: Not a number" >&2
- exit 0
- else
- let result=result+line
- let i=i+1
- fi
- done < "${1:-/dev/stdin}"
- echo $result
- echo $i
- bc -l <<< $result/$i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement