The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing between pattern Pauky UNIX for Dummies Questions & Answers 3 02-09-2009 06:19 PM
Need help in sed command ( Replacing a pattern inside a file with a variable value ) frozensmilz Shell Programming and Scripting 2 12-22-2008 06:40 AM
Sed and replacing one occurence of pattern ss9u Shell Programming and Scripting 6 07-16-2008 03:06 PM
Replacing pattern in variable videsh77 Shell Programming and Scripting 1 05-26-2005 03:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-30-2009
shivarajM shivarajM is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 12
Arrow Replacing a pattern using variable?

ip1="xxx"
ip2="bbb"

sed 's/$ip1/$ip2/g'
  #2 (permalink)  
Old 04-30-2009
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
  
 

Join Date: Jan 2009
Location: Gurgaon,INDIA
Posts: 239
sed s/"$ip1"/"$ip2"/g filename
  #3 (permalink)  
Old 04-30-2009
shivarajM shivarajM is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 12
Hi,
Double quote doesn't work but single quote works fine...........

Thank you.......
  #4 (permalink)  
Old 04-30-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
no quote also work fine

Code:
 
TEST>echo "xxx" |sed s/$ip1/$ip2/g
bbb
Closed Thread

Bookmarks

Tags
replace pattern, shell script, variables

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0