Question: Objectives: The objective of this assignment is to apply what you learned in the previous labs about Linux commands and shell programming by writing some
Objectives:
The objective of this assignment is to apply what you learned in the previous labs about Linux commands and shell programming by writing some bash shell scripts.
What to Do:
Write generalized bashshell script that are able to work correctly on any UnixLinux computer, with any user account, and starting from any working directory without any modification, to carry out each of the following tasks:
Hint: Use environment variables, string patterns, and wildcard characters to generalize your script.
Question: Safe Delete srm:
When you use the standard rm command in Linux, it will delete the specified files, with no chance for recovering them back later. Write a script called srm that will safely delete the files passed to it as commandline arguments For example, typing: srm file file fileetc.", the script shall not actually delete these files, but instead it shall move them to a trash directory and record their original paths and names in a hidden recovery record file called trashsrm
At its start, it shall always check for the existence of the directory: homeusernametrash and the file: homeusernametrashsrm if they do not exist, the script must create them. At any change to the contents of the trash, the script shall update the recovery record file accordingly. The script shall also accept switches that modify its behavior to do the following:
If the script is called with a c switch, first it shall check the trash directory for all files older than days and permanently delete them, and then perform its normal task.
If the script is called with only switch, then it shall list all the recoverable files in the trash.
If the script is called with a b switch followed by a list of files eg srm b file file file etc. or a wildcard file pattern eg srm b file then it shall not remove the files, but rather it shall recover the matching files in the trash, by moving them back to the same directories they were deleted from.
If the script is called with a w switch followed by a list of files eg srm w file file fileetc or a wildcard file pattern eg srm w file then it shall do the same as the b switch, but all matching files shall be moved to the current work directory.
If the c switch appears in the command with any of the other switches, the script shall not delete anything from the trash; ie any other switch shall override the c switch.
If conflicting switches appear in the command, then only the leftmost one shall execute.
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
