Question: 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

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!