Answered step by step
Verified Expert Solution
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 egcpptxtdat, etc. present in your current directory on Linux server. The purpose of the script mergeall 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:
mergeall.sh para para
Where the shell parameter para represents the extension and para represents the name of the merged destination file
Example: $ mergeall.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:
Your script appends all the files with the desired extension given as para present in the current folder, one by one, to the file para
After appending the files, the merged file specified in par should have the read and write permissions only to the owner, and none to the group or others.
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 nonexistence of the needed source files.
You need to test your script with a variety of files with different extensions in the current directory.
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
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