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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2009
Registered User
 

Join Date: Jun 2004
Posts: 42
Sed problem

HI,
I have a file test which content are as

APP_NAME="%APPNAME%"

Now, i m using sed command to replace the %APPNAME% with variable APPNAME.

Here variable value is as
export APPNAME="AB"

sed -i "" -e "s:%APPNAME%:$APPNAME:" ./test

test file become as

APP_NAME="AB"
Which is expected result. But when APPNAME value is "A&B" it become as

APP_NAME="%AAPPNAMEB%"

& is substituting variable name.
While it should be as( expected result)

APP_NAME="A&B"

Any one helps me.

Last edited by Saurabh78; 03-24-2009 at 09:13 AM..
Sponsored Links
  #2 (permalink)  
Old 03-24-2009
Shahul's Avatar
Registered User
 

Join Date: Aug 2008
Location: Ipswich,UK
Posts: 176
Thumbs up

Hope this helps you..


Code:
$ echo "AB"| sed 's|AB|A\&B|g'
A&B

Thanks
SHa
  #3 (permalink)  
Old 03-24-2009
Registered User
 

Join Date: Jun 2004
Posts: 42
i need to rectify my sed command.
Here nothing is fixed. The varaible valu ecould be anything.
  #4 (permalink)  
Old 03-24-2009
Moderator
 

Join Date: Feb 2007
Location: The Netherlands
Posts: 4,962
Quote:
Originally Posted by Saurabh78 View Post
HI,
I have a file test which content are as

APP_NAME="%APPNAME%"

Now, i m using sed command to replace the %APPNAME% with variable APPNAME.

Here variable value is as
export APPNAME="AB"

sed -i "" -e "s:%APPNAME%:$APPNAME:" ./test

test file become as

APP_NAME="AB"

But when APPNAME value is "A&B" it become as

APP_NAME="%AAPPNAMEB%"

& is substituting variable name. While it should be as

APP_NAME="A&B"

Any one helps me.

Code:
sed -i 's/%APPNAME%/%'$APP_NAME'%/' ./test

Regards
  #5 (permalink)  
Old 03-24-2009
Shahul's Avatar
Registered User
 

Join Date: Aug 2008
Location: Ipswich,UK
Posts: 176
Oops..sorry saurab..i misunderstood....

Thanks Franklin

THank
Sha
Sponsored Links
Closed Thread

Bookmarks

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Loop problem with one more problem aliahsan81 Shell Programming and Scripting 3 01-07-2009 02:02 AM
problem in finding a hardware problem girish.batra Solaris 8 09-09-2008 11:10 AM
ssh script problem problem pcjandyala Shell Programming and Scripting 2 07-31-2008 04:27 PM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 11:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 10:12 AM



All times are GMT -4. The time now is 08:53 PM.


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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0