Question: In this assignment, there are 2 problems. Please make sure the coding solution is clear as possible. Also, after you finish the coding, can you

 In this assignment, there are 2 problems. Please make sure the
coding solution is clear as possible. Also, after you finish the coding,
In this assignment, there are 2 problems.
Please make sure the coding solution is clear as possible. Also, after you finish the coding, can you please provide the commands you use to check if the coding is right or working.

Problem 1 As you know, rm (short for remove) is a Unix/Linux command which is used to delete files from a filesystem and rmdir (short for remove directory) is a Unix/Linux command used to delete ectories/folders from the filesystem. When rm or rmdir command is used with the file/directory dir name(s), it deletes all given files/directories without need for user's confirmation. Furthermore, in any pure Unix/Linux system, removed files and/or directories cannot be (no trash container exists that holds files/directories for you after you deleted them). For example, if you issue a command abc.txt, it will delete file abc.txt from your working directory without any farther warnings. When you issue a command rm abc.txt def.txt, it will delete both files abc tot' and def bot from your working directory without any farther warnings. And when you issue a command rmdir My it will delete all directories in your working directory which names start with My without any farther warmingss As you see, using commands rm and rmdir is fairly.dangerous, since, especially when using wildcards you can inadvertently delete files/directories that you did not intended to. The goal of this problem is to write a script to remediate the shortcomings of rm and rmdir. You (s), file(s) or directoriy(ies) and will write a script that allows user to pass to it, as positional parameter stores them in a specific location on your filesystem before removing them permanently from their current Your script should Check if a directory Trash exists under the Root directory (ie, check ifITrash 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) 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 argument was received and exit with a non-zero user that no valid ts a valid file, copy the files to the ITrash if the argument represent directory and permanently remove it from its initial location ts a valid directory, copy the directory and all if the argument represen its content (subdirectories and/or files it contains) to the ITrash directory and permanently remove the directory from its initial location For example, assume that your script is named my script sh. If a user invokes it by typing my script sh file name, your script (ie., my script.sh) should: check if Trash exists and creates it if not, (i) check if file name is a simple file, or directory, or neither, and (iii if the file name is a file or directory, copy it to rTresh and remove from whenever it is now. Note that you have to check if file name represents a simple file or a directory since you need to use different commands to copy and delete files than directories. Also, note that if the directory to be deleted is not empty, you have to copy and remove the directory with all its co Problem 1 As you know, rm (short for remove) is a Unix/Linux command which is used to delete files from a filesystem and rmdir (short for remove directory) is a Unix/Linux command used to delete ectories/folders from the filesystem. When rm or rmdir command is used with the file/directory dir name(s), it deletes all given files/directories without need for user's confirmation. Furthermore, in any pure Unix/Linux system, removed files and/or directories cannot be (no trash container exists that holds files/directories for you after you deleted them). For example, if you issue a command abc.txt, it will delete file abc.txt from your working directory without any farther warnings. When you issue a command rm abc.txt def.txt, it will delete both files abc tot' and def bot from your working directory without any farther warnings. And when you issue a command rmdir My it will delete all directories in your working directory which names start with My without any farther warmingss As you see, using commands rm and rmdir is fairly.dangerous, since, especially when using wildcards you can inadvertently delete files/directories that you did not intended to. The goal of this problem is to write a script to remediate the shortcomings of rm and rmdir. You (s), file(s) or directoriy(ies) and will write a script that allows user to pass to it, as positional parameter stores them in a specific location on your filesystem before removing them permanently from their current Your script should Check if a directory Trash exists under the Root directory (ie, check ifITrash 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) 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 argument was received and exit with a non-zero user that no valid ts a valid file, copy the files to the ITrash if the argument represent directory and permanently remove it from its initial location ts a valid directory, copy the directory and all if the argument represen its content (subdirectories and/or files it contains) to the ITrash directory and permanently remove the directory from its initial location For example, assume that your script is named my script sh. If a user invokes it by typing my script sh file name, your script (ie., my script.sh) should: check if Trash exists and creates it if not, (i) check if file name is a simple file, or directory, or neither, and (iii if the file name is a file or directory, copy it to rTresh and remove from whenever it is now. Note that you have to check if file name represents a simple file or a directory since you need to use different commands to copy and delete files than directories. Also, note that if the directory to be deleted is not empty, you have to copy and remove the directory with all its co

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!