Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-21-2012, 05:39 PM
|
#1
|
|
LQ Newbie
Registered: Apr 2012
Posts: 5
Rep: 
|
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.
|
|
|
|
04-21-2012, 05:43 PM
|
#2
|
|
Member
Registered: Mar 2012
Posts: 356
Rep:
|
Maybe you should have paid attention in the class this homework is for ...
|
|
|
|
04-21-2012, 05:49 PM
|
#3
|
|
LQ Newbie
Registered: Apr 2012
Posts: 5
Original Poster
Rep: 
|
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.
|
|
|
|
04-21-2012, 06:39 PM
|
#4
|
|
Guru
Registered: Aug 2005
Posts: 9,530
|
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"........... "
Last edited by John VV; 04-21-2012 at 06:42 PM.
|
|
|
|
04-21-2012, 07:42 PM
|
#5
|
|
LQ Newbie
Registered: Apr 2012
Posts: 5
Original Poster
Rep: 
|
I just need an sed command that rewrites a file to a different file extension
|
|
|
|
04-21-2012, 10:01 PM
|
#6
|
|
Guru
Registered: Aug 2005
Posts: 9,530
|
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
|
|
|
|
04-21-2012, 11:46 PM
|
#7
|
|
Senior Member
Registered: May 2005
Location: boston, usa
Distribution: fc-12/ fc-11-live-usb/ aix
Posts: 2,670
|
man sed
|
|
|
|
04-22-2012, 03:17 AM
|
#8
|
|
Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 6,312
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:19 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|