Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #! /bin/sh
  2.  
  3. if [ $# -ls 2 ]
  4. then
  5.     echo "Usage: $0 <file> n1 n2 ..."
  6.     exit 1
  7. fi
  8.  
  9.  
  10. if ! [ -f $1 ]
  11. then
  12.     echo "$1 is not a regular file"
  13.     exit 1
  14. fi
  15.  
  16.  
  17. while read line
  18. do
  19.     rez=`echo $linie | grep '[0-9]+'`
  20.     if ! [ -z "$rez" ]
  21.     then
  22.         nr=$rez
  23.         break
  24.     else
  25.         echo "Number not found"
  26.         exit 1
  27.     fi
  28. done < $1
  29.  
  30. for i in ${@:2}
  31. do
  32.     if [ $(($i % $nr)) -eq 0 ]
  33.     then
  34.     c=$c + ${#i}
  35.     echo "Primul nr are $c cifre.  "
  36.     fi
  37. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement