Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!bin/bash
  2.  
  3. bashname=$0
  4. basharguments=$#
  5. args=("$@")
  6. number=2
  7. countEven=0
  8. sum=0
  9. filename=$1
  10.  
  11. if test "$#" -eq 1
  12. then
  13. echo "Usage:bash $bashname"
  14. exit
  15. fi
  16.  
  17. while test $number -ne $basharguments
  18. do
  19. if(( ${args[number]} % 2 == 0 ))
  20. then
  21. countEven=`expr $countEven + 1`
  22. fi
  23. number=`expr $number + 1`
  24. done
  25. echo "$countEven"
  26.  
  27.  
  28. shift
  29. for arg
  30. do
  31. sum=`expr $sum + $arg`
  32. done
  33.  
  34. echo "$sum"
  35.  
  36. d=`echo $sum | wc -L`
  37.  
  38. echo "$d"
  39.  
  40. if test -f "$filename"
  41. then
  42. echo $sum > $filename
  43. echo $d >> $filename
  44. elif test -h "$filename"
  45. then
  46. echo "File is symbolic"
  47. else
  48. echo "Error message"
  49. fi
  50.  
  51. command=`cat $filename`
  52.  
  53. echo "What is in the file:"
  54. echo "$command"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement