Question: In C++, please. Copy & paste what I gave you into your own file rn (see below), and try it out. Make sure that the

In C++, please.

Copy & paste what I gave you into your own file rn (see below), and try it out. Make sure that the first two characters in the script are #!, with nothing before them. Make it actually rename the file, rather than just saying so. Add a usage message if too many or too few arguments are given. A usage message is a message that tells the user what arguments to give to this script, if an improper number of arguments (including none) are given. Send the usage message to standard error. Complain (to standard error) and stop the script if a file cant be renamed. Not clobber existing files. That is, if we run the script like this: ./rn foo bar and both alpha.foo and alpha.bar exist, the script should complain and refuse to do anything else.

#! /bin/bash

old_suffix=$1 new_suffix=$2

for f in *.$old_suffix do new_name=${f%.*}.$new_suffix echo Rename $f to $new_name done

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!