Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a BASH SCRIPT: All of the paths used must be relative. You must use variable names for the directories in all paths. This script

Write a BASH SCRIPT: All of the paths used must be relative. You must use variable names for the directories in all paths. This script must: Be able to take in 2 directories as positional parameters. The first one will be the source directory and needs to get stored in variable $source_dir. The second is the destination directory and needs to get stored in $dest_dir. Test to see if those variables are valid directories and if they are not send the user into a while loop to enter the directory and only allow exit when a valid directory is entered. Use touch to create files in the source directory to test with. Using curly brace syntax to expand a pattern create files in the pattern a .error.log b .error.log all the way through z .error.log and make sure they have the space in the file name. Use touch to create more files in the source directory to test with. Using curly brace syntax to expand a pattern create files in the pattern 1 _file.txt 2 _file.txt all the way through 9 _file.txt and make sure they have the space in the file name. Test to see if the directory $dest_dir/logs exists and if it does not create it. Test to see if the directory $dest_dir/text exists and if it does not create it. Use a for in loop to iterate through all of the files in the source directory. Inside the for in loop test the files. Put the files ending in .log in $dest_dir/logs. Echo out a message indicating the file being moved and to what directory it is being moved. Put the files ending in .txt inside of $dest_dir/text. Echo out a message indicating the file being moved and to what directory it is being moved. For files not matching either condition echo out a message indicating you are leaving the file alone.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

Students also viewed these Databases questions

Question

c. Will leaders rotate periodically?

Answered: 1 week ago

Question

b. Will there be one assigned leader?

Answered: 1 week ago