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
Unix Arithmatic operation issue , datatype issue thambi Shell Programming and Scripting 23 02-19-2008 07:19 AM
Variable Substitution Issue calredd SUN Solaris 4 02-16-2008 11:42 AM
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 08:28 PM
Variable for -name causing issue in Find command ParNone UNIX for Dummies Questions & Answers 2 03-24-2006 06:48 PM
ksh/Linux: Variable scoping issue? Pl. help! jasmeet100 Shell Programming and Scripting 2 09-30-2005 06:35 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 11-27-2006
wisher115 wisher115 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 18
sed variable issue

I'm writting a krn shell script and i'm having an issue with a variable using sed.
If someone enters a variable with a " /" the sed command doesn't read it right.
example.
a='12000/10-DC'
b='12000/10-AC'

cat file | sed "s/$a/$b/"

How can i correct this issue? Will the fix to this problem also work if someone enters a variable without a " /" ? What is it called when a variable has a character like this? I didn't know how to search for this issue correctly.
Thanks.
  #2 (permalink)  
Old 11-27-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,723
Here is one workaround -- use delimiting characters that are not in the user-defined strings (assumes the # character is not in the strings):
Code:
a='12000/10-DC'
b='12000/10-AC'

cat file | sed "s#$a#$b#"
  #3 (permalink)  
Old 11-27-2006
wisher115 wisher115 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 18
Thanks it worked.
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 On




All times are GMT -4. The time now is 06:02 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