Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- if [ $# -lt 3 ]
- then
- echo "Usage: $0 <file> <digit> <...>"
- exit
- fi
- if [ $2 -lt 0 -o $2 -gt 9 ]
- then
- echo "Second argument must be a digit."
- exit
- fi
- k=0
- s=0
- for n in "${@:2}"
- do
- if [ $(($n % 10)) -eq $2 ]
- then
- echo "$n are uc $2"
- k=$(($k + 1))
- s=$(($s + $n))
- fi
- done
- aux=$s
- c=0
- while [ $aux -gt 0 ]
- do
- aux=$(($aux/10))
- c=$(($c+1))
- done
- if [ -f $1 ]
- then
- echo "Suma este $s si are $c cifre" > $1
- else
- echo "$1 is not a regular file"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement