SHARE
TWEET

Untitled

a guest Dec 2nd, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2.  
  3. if [ $# -lt 2 ]
  4. then
  5.     echo "Usage: $0 <file> n1 n2 ..."
  6.     exit 1
  7. fi
  8.  
  9.  
  10. s=0
  11. nr=0
  12.  
  13.  
  14. if [ -f $1 ]
  15. then
  16. while read line
  17. do
  18.      rez=`echo $line | grep -Eo '[0-9]+'`
  19.     if ! [ -z "$rez" ]
  20.     then
  21.         nr=$rez
  22.         break
  23.     fi
  24. done < $1
  25.  
  26. echo "$nr"
  27.  
  28.  
  29. if [ $nr -eq 0 ]
  30. then
  31.     echo "Number not found"
  32. else
  33.  
  34. for i in "${@:2}"
  35. do
  36.     if [ $(($i % $nr)) -eq 0 ]
  37.     then
  38.     s=$(($s + ${#i}))
  39.     echo "Nr $i are ${#i} cifre"
  40.     fi
  41. done
  42. fi
  43.  
  44. else
  45.  echo "$1 is not a regular file"
  46.     exit 1
  47. fi
  48.  
  49. echo "$s"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top