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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing a pattern using variable? shivarajM Shell Programming and Scripting 3 04-30-2009 03:30 AM
Help in replacing text with the value of a variable lotto_123 Shell Programming and Scripting 4 06-13-2008 07:39 AM
Replacing $ in variable ashish_uiit UNIX for Dummies Questions & Answers 10 02-29-2008 09:29 AM
Replacing set of characters with a value of a variable prekida Shell Programming and Scripting 1 07-26-2005 08:14 PM
Replacing pattern in variable videsh77 Shell Programming and Scripting 1 05-26-2005 02:11 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-25-2009
belfastbelle belfastbelle is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 14
Replacing in a variable

Hi,

If I have a variable
var1 ='TH 12/1234'

How can I set this too in a script
var1 ='TH 12~1234'

Bearing in mind "/" might be in a difference place each time and that the "/" might not even exist each time
the variable is set.

Thanks
  #2 (permalink)  
Old 06-25-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Start with this idea:
Code:
echo "$var1" | tr -s '/' '~' | read tmp
var1=$tmp
  #3 (permalink)  
Old 06-26-2009
bdragon bdragon is offline
Registered User
  
 

Join Date: Jun 2009
Location: Tampa FL USA
Posts: 7
Or:
Code:
var1=$(echo $var1|tr -s '/' '~')
This should work in BASH or ksh.

Last edited by Yogesh Sawant; 06-30-2009 at 04:03 AM.. Reason: added code tags
  #4 (permalink)  
Old 06-26-2009
belfastbelle belfastbelle is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 14
Thanks - that works a treat !!
Sponsored Links
Reply

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 08:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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