Question: LAB EXERCISE 2 You are now going to modify the script you write for Lab Exercise 1 D to see if a master file exists
LAB EXERCISE
You are now going to modify the script you write for Lab Exercise D to see if a master file exists and, if it doesn't, create one. Then, in the loop, you will ignore any nonregular files and the master file.
A At the beginning of the script, add a line that defines a variable called MASTER, and give it the initial value "MasterList". Call this script
scanapy When you are done, save a copy because you will use this in Lab Exercise
After the variable definition but before your loop, test to see if the file named by the value of the variable MASTER exists. If so print the message that the file "exists; please delete it and exit, giving exit status code If not, create it Call this script
scanbpy
c In the for loop, before you print the file attributes, check to see if the file being examined is either a regular file or the MasterList file. If it is neither, immediately go to the next file that is do not get the file attributes Call this script
scancpy
d Modify your script so that the attributes are stored in the file named by the value of the variable MASTER. Call this script
scandpy
E Finally, if everything works, have the script exit with an exit status code of Call this script
scanepy
Run your script. There should be no output. Then look for a file called MasterList and compare its contents to what you got for the output of
scriptsh The outputs for the files abc xyz abcde,
demo.for.sh
demoforsh and demoforsh should be the same. The other files that are present should all be ones you created or put there.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
