Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "Creating test files for question one"
- if touch file1.txt
- then
- echo "Created file1.txt"
- else
- echo "Could not create file1.txt"
- exit 1
- fi
- if touch file1.doc
- then
- echo "Created file1.doc"
- else
- echo "Could not create file1.doc"
- exit 1
- fi
- if touch file1.pdf
- then
- echo "Created file1.pdf"
- else
- echo "Could not create file1.pdf"
- exit 1
- fi
- echo "Checking if file1.txt/doc/pdf exist and that file1.rtf does not exist"
- if [ -e file1.txt ] && [ -e file1.doc ] && [ -e file1.pdf ] && [ ! -e file1.rtf ]
- then
- echo "file1.txt/pdf/doc exist, file1.rtf does not exist, now running q1.sh to try and remove it"
- if ./q1.sh txt rtf
- then
- if [ ! -e file1.txt ] && [ -e file1.pdf ] && [ -e file1.doc ] && [ -e file1.rtf ]
- then
- echo "File successfully renamed and all other files unchanged! Goodbye!"
- rm file1.*
- exit 0
- else
- echo "Something went wrong!"
- exit 1
- fi
- fi
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement