Advertisement
Xioth

Bash - TP3 - create-ball3.sh

Jan 18th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. if [ $# = 0 ]
  4. then
  5.  
  6. cat << END_MY-BALL > my-ball.sh
  7. cat << TAG_CAT > my-id.txt
  8. NOM
  9. Prénom
  10. adresse@mail.com
  11. TAG_CAT
  12. END_MY-BALL
  13.  
  14. elif [ $# -gt 1 ]
  15. then
  16.     if [ ! -f "my-ball.sh" ]
  17.     then
  18.         touch my-ball.sh
  19.     else
  20.         cat /dev/null > my-ball.sh
  21.     fi
  22.  
  23.     chmod 755 my-ball.sh
  24.  
  25.     for element in $@
  26.     do
  27.         if [ -f $element ]
  28.         then
  29.  
  30. cat << END_MY-BALL > my-ball.sh
  31. cat $element > "$element.recreated"
  32. END_MY-BALL
  33.  
  34.         ./my-ball.sh
  35.         else
  36.             echo "$element : Introuvable"
  37.         fi
  38.     done
  39. else
  40.     echo "Ce programme n'accepte qu'un seul paramètre au maximum !"
  41.     exit 1
  42. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement