Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-31-2007, 05:48 PM   #1
LQ Newbie
Registered: Oct 2007
Posts: 6

Rep: Reputation: 0
renaming file extensions

i understand WHY this will not work, and i see many scripts on-line that do ALMOST the same thing, but not quite....
i want to rename all the files with exentsion: .bas-new to simply: .bas
how can i do that.
# called like: ./ *.bas-new

for filename in "$@";
rename *.bas-new *.bas
Old 10-31-2007, 06:22 PM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Part of the Pleasure of Linux is the challange. So here's the challenge. Study the use of grep and sed, and their use in a bash script.

Then, in your sudo code, change
rename *.bas-new *.bas
grep # to select only those lines with the regular expression
sed -e <substitute /> # to change to bas

Last edited by bigrigdriver; 10-31-2007 at 06:23 PM.
Old 10-31-2007, 06:28 PM   #3
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Have a look at the man page for rename (if your distro provides it). You could do something like:
rename 'bas-new' 'bas' *bas-new


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming multipe files without extensions DIMonS Programming 3 08-09-2007 12:29 PM
renaming extensions christina_rules Linux - Newbie 6 05-23-2006 10:04 AM
bash help, renaming file extensions trey85stang Linux - General 8 07-21-2005 05:51 PM
renaming a file?? U-Toast Linux - Newbie 2 08-29-2004 02:07 AM
renaming or converting a text file to a dat file... tangaz Linux - Software 1 10-24-2003 07:57 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration