Advertisement
sandervanvugt

Untitled

Jun 23rd, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. 1 #!/bin/bash
  2. 2
  3. 3 #
  4. 4 #
  5. 5 #
  6. 6
  7. 7 if [ -z $1 ]
  8. 8 then
  9. 9 echo no argument
  10. 10 exit 2
  11. 11 elif [ ! -e $1 ]
  12. 12 then
  13. 13 echo unknown argument
  14. 14 exit 3
  15. 15 elif [ -d $1 ]
  16. 16 then
  17. 17 echo it\'s a directory
  18. 18 # at this point it must be a file, let's find out what type of file
  19. 19 elif [ ! -f $1 ]
  20. 20 then
  21. 21 echo some special file
  22. 22 elif [ -x $1 ]
  23. 23 then
  24. 24 echo executable file
  25. 25 elif grep '#!/bin/bash' $1
  26. 26 then
  27. 27 echo it\'s a bash file that is not executable yet
  28. 28 chmod +x $1
  29. 29 else
  30. 30 echo this is a non-executable file it appears
  31. 31 fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement