Guest User

Untitled

a guest
Apr 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.70 KB | None | 0 0
  1. #!/bin/bash
  2. STAN="0"
  3. function pusty
  4. {
  5. if [ -s "$1" ]
  6. then
  7. STAN="0"
  8. else
  9. STAN="1"
  10. echo "Plik $1 jest pusty"
  11. fi
  12. }
  13. function istnieje
  14. {
  15. if [ -f "$1" ]
  16. then
  17. STAN="0"
  18. else
  19. STAN="1"
  20. echo "Plik $1 nie istnieje lub nie jest zwyklym plikiem"
  21. fi
  22. }
  23. function odczyt
  24. {
  25. if [ -r "$1" ]
  26. then
  27. STAN="0"
  28. else
  29. STAN="1"
  30. echo "Nie mamy prawa odczytu pliku $1"
  31. fi
  32. }
  33.  
  34. if [ "$#" -ge 2 ]
  35.  then
  36.         if [ -w $1 ]
  37.      then
  38.         for i in $*; do
  39.     pusty $i
  40.     if [ $STAN -eq 1 ]
  41.     then
  42.     break
  43.     fi
  44.     istnieje $i
  45.     if [ $STAN -eq 1 ]
  46.     then
  47.     break
  48.     fi
  49.     odczyt $i
  50.     if [ $STAN -eq 1 ]
  51.     then
  52.     break
  53.     fi
  54.     if [ "$i" != "$1" ]
  55.     then
  56.     cat $i>>$1
  57.     fi
  58.     done
  59.      else
  60.     echo "Nie mozna zapisywac"
  61. fi
  62. fi
Add Comment
Please, Sign In to add comment