Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume that you have several files, with different extensions ( e . g . , . cpp , . txt , . dat, etc. )

Assume that you have several files, with different extensions (e.g.,.cpp,.txt,.dat, etc.), present in your current directory on Linux server. The purpose of the script merge_all is to merge all files present in your directory with an extension (provided by the user) into one single file.
We need to write and test a bash script that is invoked as:
./ merge_all.sh para1 para2
Where the shell parameter para1 represents the extension and para2 represents the name of the merged (destination file).
Example: $ ./merge_all.sh txt Backup
The above command will append all .txt files in the current directory to the file named Backup.
Some important features of your script:
1. Your script appends all the files with the desired extension (given as para1) present in the current folder, one by one, to the file para2.
2. After appending the files, the merged file specified in par2 should have the read and write permissions only to the owner, and none to the group or others.
3. Your script should not make any assumption about the number and types of files present in the current directory. Appropriate messages should be printed in case of non-existence of the needed source files.
4. You need to test your script with a variety of files with different extensions in the current directory.
5. You will need to do a little research about extracting the extension type of a file in bash and about appending a file to another.

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Describe the major steps leading to the formation of a blood clot.

Answered: 1 week ago