LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-29-2007, 05:45 AM   #1
bhert
Member
 
Registered: May 2006
Distribution: OpenSUSE 10.3 Kubuntu Hardy Heron
Posts: 268

Rep: Reputation: 30
shell scripting question


Hello guys! I don't know if it's the right place for this kind of question.

In my file, I have names that begins with The.
What I want to do is move the word The to the end of the name with a comma.
for example,

The black hole
The mighty Ducks
change to

black hole,The
mighty ducks,The

What is the easiest way to get that done? Thanks

-bhert
 
Old 01-29-2007, 06:07 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
sed -e 's/^The \(.*\)/\1, The/' -i file
 
Old 01-29-2007, 08:55 PM   #3
bhert
Member
 
Registered: May 2006
Distribution: OpenSUSE 10.3 Kubuntu Hardy Heron
Posts: 268

Original Poster
Rep: Reputation: 30
Thanks raskin, works like a charm!
I didn't know about the -i option for sed, great thing to use!

-bhert
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripting question creolophus Linux - Software 1 10-02-2006 02:13 AM
shell scripting question JSLayton Linux - General 4 06-01-2006 06:55 AM
a shell-scripting question: mrchaos Slackware 3 09-22-2005 11:00 AM
Shell Scripting Question Onyx^ Linux - General 5 04-27-2004 10:37 AM
Shell Scripting Question b_vasu Linux - Newbie 1 11-21-2003 02:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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