Question
In this exercise, you will create a script called file_ops.sh that uses the various file operators The file_ops.sh script will Use one command line argument
In this exercise, you will create a script called file_ops.sh that uses the various file operators The file_ops.sh script will Use one command line argument Use four IF THEN statement to compare the first command line argument Determine which file operators to use that produces the following output when the script run with the arguments shown WARNING: In the IF THEN statements, to avoid syntax error messages, there must be a space before and after each bracket and also between each element within the brackets. Watching the video about File Test Operators may be helpful Look at the slide "File Operators" The first IF THEN statement has the form If [ operator $1 ] then echo "" fi Decide which operator to use that produces the message " exists and is a file" The second IF THEN statement has the form If [ operator $1 ] then echo "" fi Decide which operator to use that produces the message " exists" The third IF THEN statement has the form If [ operator $1 ] then echo "" fi Decide which operator to use that produces the message " does not exist" The fourth IF THEN statement has the form if [ ! operator $1 ] then echo "" fi Decide which operator to use that produces the message " exists and is a directory" Type the following commands. NOTE: You do not need to use 'gedit' to create your shell script. You can use 'vi' or 'nano' if you prefer Ignore anything highlighted in red as they are just comments 'clear' // Clear the screen 'cd ~/scripting_lab' // Change to the lab directory using tilde 'gedit file_ops.sh' // create the script using the editor of choice 'cat n file_ops.sh' // show the script contents // You will run file_ops.sh four times without changes to the script 'sh file_ops.sh /etc/passwd' // file exists 'sh file_ops.sh /etc/passwdd' // file does not exist 'sh file_ops.sh /etc' // directory 'sh file_ops.sh /etcc' // directory does not exist 'date' Using Snipping Tool, take a screenshot
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started