Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #!/bin/bash
  2. echo "Creating test files for question one"
  3. if touch file1.txt
  4. then
  5. echo "Created file1.txt"
  6. else
  7. echo "Could not create file1.txt"
  8. exit 1
  9. fi
  10. if touch file1.doc
  11. then
  12. echo "Created file1.doc"
  13. else
  14. echo "Could not create file1.doc"
  15. exit 1
  16. fi
  17. if touch file1.pdf
  18. then
  19. echo "Created file1.pdf"
  20. else
  21. echo "Could not create file1.pdf"
  22. exit 1
  23. fi
  24.  
  25. echo "Checking if file1.txt/doc/pdf exist and that file1.rtf does not exist"
  26. if [ -e file1.txt ] && [ -e file1.doc ] && [ -e file1.pdf ] && [ ! -e file1.rtf ]
  27. then
  28. echo "file1.txt/pdf/doc exist, file1.rtf does not exist, now running q1.sh to try and remove it"
  29. if ./q1.sh txt rtf
  30. then
  31. if [ ! -e file1.txt ] && [ -e file1.pdf ] && [ -e file1.doc ] && [ -e file1.rtf ]
  32. then
  33. echo "File successfully renamed and all other files unchanged! Goodbye!"
  34. rm file1.*
  35. exit 0
  36. else
  37. echo "Something went wrong!"
  38. exit 1
  39.  
  40. fi
  41. fi
  42. fi
  43. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement