Share your knowledge at the LQ Wiki.
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 12-17-2008, 06:58 AM   #1
Registered: Dec 2007
Posts: 73

Rep: Reputation: 15
sed : how to use delimiter


i have a file like:

it is for
the format is

now my problem is when i give this sed command :

sed 's/for/sfor/g'

it replaces "for" as well as "format" so how to delimit this so that the output should be:

it is sfor
the format is


it is sfor
the sformat is
Old 12-17-2008, 07:06 AM   #2
LQ Veteran
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,690
Blog Entries: 1

Rep: Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106
sed 's/\<for\>/sfor/g'
Old 12-17-2008, 07:41 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735
Really good SED tutorial here:

Keep in mind that SED is literal---in your example, "for" does not mean the word "for"--it means those three letters in sequence.


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
xls2csv delimiter waelaltaqi Linux - Newbie 5 03-27-2008 11:05 PM
getline delimiter + move to next line? blizunt7 Programming 3 07-09-2005 01:08 AM
c++ get() delimiter ashirazi Programming 3 08-06-2004 06:26 AM
sed with delimiter, bourne uribo Programming 17 04-23-2003 02:42 AM
tab delimiter codename000 Programming 3 04-04-2003 11:18 AM

All times are GMT -5. The time now is 11:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration