Question
Write a bash shell script that : 1-Check if a directory Trash exists under the Root directory (i.e., check if /Trash exists on the computer
Write a bash shell script that :
1-Check if a directory Trash exists under the Root directory (i.e., check if /Trash exists on the computer the scripts is running) - If yes, do nothing - If no, create it and check if it was successfully created (check for the return value of the command that creates a new directory)
2- Take as an input name(s) of the file(s) and/or directory(ies)
- If no argument (file name) was passed, warn a user that no argument was passed and exit with a non-zero status.
- If at least one argument was passed, check if it(they) is(are) simple file(s), directories, or others ~
-if passed argument is not representing the file or directory, warn the user that no valid argument was received and exit with a non-zero status ~
- if the argument represents a valid file, copy the files to the /Trash directory and permanently remove it from its initial location ~
-if the argument represents a valid directory, copy the directory and all its content (subdirectories and/or files it contains) to the /Trash directory and permanently remove the directory from its initial location
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