Write Shell Script Accepts Two File Extensions Command Line Arguments Renames Files First Q37130400

Write a shell script that accepts two file extensions as commandline arguments and renames all files with the first extensionwithin the current working directory to have the second extensioninstead.

For example:

$ reextend .log .txt

Would cause install.log to be renamed to install.txt, and

$ reextend A B

Would cause TADAA to be renamed to TADAB . It would also causefile.A to be renamed file.B .

The script should print out error messages as is appropriate ifthere is any problem with the command line arguments. Test thescript with a range of different parameters, including incorrectparameters or missing parameters.


Solution


#!/bin/bash

#check the two command line arguments are

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.