LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help with UNIX Shell Scripts (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-unix-shell-scripts-941039/)

Pampano 04-21-2012 05:39 PM

Help with UNIX Shell Scripts
 
What if I had many files but needed to change the extensions of them and they all have different extensions.

For example, I need an sed command to change the file "batman.CPP" to be "batman.cpp"

And I also have a file "kingsandqueens.dat" and I need it to be "kingsandqueens.backup"


I need a shell script that will do this for me if I were to execute the program as ./chExt1.sh 'cpp' 'batman.CPP'
or ./chExt1.sh 'backup' 'kingsandqueens.dat'

Thanks for any help with this.

descendant_command 04-21-2012 05:43 PM

Maybe you should have paid attention in the class this homework is for ...

Pampano 04-21-2012 05:49 PM

I did pay attention. This is the last assignment. I didn't ask for the answer, just "any help" because I am struggling with how to get started.

John VV 04-21-2012 06:39 PM

post what you have so far

also for changing CAP to lower case there are small shell scripts already posted all over the net
almost EVERY tutorial site would have something
a simple " for i in *; do mv "$i"........... "

Pampano 04-21-2012 07:42 PM

I just need an sed command that rewrites a file to a different file extension

John VV 04-21-2012 10:01 PM

Quote:

I just need an sed command that rewrites a file to a different file extension
and you have been asked twice to post what you have so far

schneidz 04-21-2012 11:46 PM

man sed

grail 04-22-2012 03:17 AM

Not sure why you would use sed at all. As suggested a simple loop and the mv command would be enough or if your distro has it have a look for the rename command.


All times are GMT -5. The time now is 10:59 PM.