The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to replace string scorp_rahul23 Shell Programming and Scripting 4 09-22-2008 11:37 PM
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 2 04-11-2008 11:32 AM
replace string in XML with sed chiru_h Shell Programming and Scripting 6 04-09-2008 04:49 PM
Replace string B depending on occurence of string A hemangjani Shell Programming and Scripting 1 12-05-2006 02:10 PM
How to replace within a string aukequist Shell Programming and Scripting 2 02-07-2006 04:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-01-2008
Registered User
 

Join Date: Jun 2008
Posts: 25
Replace string

Hi

a.txt

abc|xyz
abc|zyc


I want to replace abc with abc1/abc2 using sed

I tried with but its not working

sed 's/abc/\abc1/abc2\/g' a.txt

Thanks,
Akil
Reply With Quote
Forum Sponsor
  #2  
Old 10-01-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
Code:
sed 's/abc/abc1\/abc2/' a.txt
Regards
Reply With Quote
  #3  
Old 10-01-2008
vidyadhar85's Avatar
The Tutor
 

Join Date: Jun 2008
Location: INDIA
Posts: 543
try this
Code:
sed 's/abc/abc1\/abc2/g'
Reply With Quote
  #4  
Old 10-01-2008
Registered User
 

Join Date: Jun 2008
Posts: 25
Hi
Thanks,Its working

Thanks,
Akil
Reply With Quote
  #5  
Old 10-01-2008
Registered User
 

Join Date: Sep 2008
Posts: 22
sometimes it helps to change the deliminator'



sed 's!abc!abc1\/abc2!' a.txt

does not have to be a / !!!!!!!!!!!!!!!!, but you must do a \ to exit the meta char "/" is a meta char,, see google regx
sed 's|abc|abc1\/abc2|' a.txt
Reply With Quote
  #6  
Old 10-01-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
No, you don't need the backslash if you use a different delimiter.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0