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 using sed shailesh_arya Shell Programming and Scripting 2 07-11-2008 01:06 AM
help in replacing ?? zedex Shell Programming and Scripting 5 08-31-2007 02:45 AM
Replacing in SED superprogrammer Shell Programming and Scripting 8 07-11-2006 03:33 AM
replacing with `pwd` oldtrash Shell Programming and Scripting 6 04-09-2004 07:24 PM
replacing \n by \r\n crashnburn UNIX for Dummies Questions & Answers 3 11-24-2003 03:49 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 Rating: Thread Rating: 1 votes, 3.00 average. Display Modes
  #1 (permalink)  
Old 12-08-2008
rudoraj rudoraj is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 41
replacing / to -

Hi,
i am running a shell script where i have assigned a variable to the value passed.

so my variable is
var1="investment/portfolio/run.job"

now i want to assign another variable var2 as

"investment-portfolio-run.out"

how can i do it using awk or something else....

thanks
  #2 (permalink)  
Old 12-08-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Code:
# echo "investment/portfolio/run.job" | sed 's/\//\-/g'
investment-portfolio-run.job
Code:
var1="investment/portfolio/run.job"

var2=`echo $var1 | sed 's/\//\-/g'`

echo $var2
  #3 (permalink)  
Old 12-08-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
these two will also do
Code:
echo "investment/portfolio/run.job" |tr "/" "-"
Code:
echo "investment/portfolio/run.job" |awk '/\//{gsub("/","-")}{print}'
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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

Content Relevant URLs by vBSEO 3.2.0