LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 12-17-2008, 05:58 AM   #1
Ashok_mittal
Member
 
Registered: Dec 2007
Posts: 73

Rep: Reputation: 15
sed : how to use delimiter


Hi,

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
...

not

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

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

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Really good SED tutorial here:
http://www.grymoire.com/Unix/Sed.html

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


Reply


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


All times are GMT -5. The time now is 02:00 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration