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
read a variable character by character, substitute characters with something else vipervenom25 UNIX for Dummies Questions & Answers 2 06-06-2008 03:18 PM
[csh] checking for specific character ranges in a variable userix Shell Programming and Scripting 5 05-11-2008 07:56 AM
Removing character ' from a variable sertansenturk Shell Programming and Scripting 3 04-19-2008 08:53 AM
Search in variable for character rorey_breaker Shell Programming and Scripting 1 09-27-2007 07:05 AM
defining a variable as a number or character? noobian UNIX for Dummies Questions & Answers 1 04-26-2005 08:19 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 03-13-2008
potro's Avatar
potro potro is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 61
Sed a variable which has - character in it

Hi

Because my GR_RESOURCE_DIR variable has - character in it the sed doesn't work. Could you please advise ?

[root@skynet conf]# cat globalrelay.ini
[Basic Configuration]
ResourceDIR=/app-nfs/meta/relay

[root@skynet bianca]# cat xac.sh
#!/bin/bash
#XAC_INSTALL_PATH=/usr/XenonAdministrationCenter
GR_RESOURCE_DIR=new-app

sed -e "s-\(^ResourceDIR=\)\([^#]*\)-\1${GR_RESOURCE_DIR}-" aaaa > bbbb

[root@skynet bianca]# ./xac.sh
sed: -e expression #1, char 36: unknown option to `s'

Thanks,
Bianca
  #2 (permalink)  
Old 03-13-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
What exactly are you trying to do here?

Change "ResourceDIR=/app-nfs/meta/relay" to "ResourceDIR=new-app?
Change "ResourceDIR=/app-nfs/meta/relay" to "ResourceDIR=/new-app/meta/relay?
  #3 (permalink)  
Old 03-13-2008
potro's Avatar
potro potro is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 61
Quote:
Originally Posted by fpmurphy View Post
What exactly are you trying to do here?

Change "ResourceDIR=/app-nfs/meta/relay" to "ResourceDIR=new-app?
Change "ResourceDIR=/app-nfs/meta/relay" to "ResourceDIR=/new-app/meta/relay?

I want to replace everythig after ResourceDIR= with the variable read during install.

I want to specify that another parameter that need to be replace is
MountFolderLive=/live/, /app-nfs/meta/relay
and here only /app-nfs/meta/relay to be replaced with the variable read.

Thanks
Bianca

Last edited by potro; 03-13-2008 at 05:45 AM..
  #4 (permalink)  
Old 03-13-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
Try the following:

Code:
sed -e "s|\(^ResourceDIR=\)\([0-9a-zA-Z\/\-]*$\)|\1${GR_RESOURCE_DIR}|" infile > outfile
  #5 (permalink)  
Old 03-14-2008
potro's Avatar
potro potro is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 61
Quote:
Originally Posted by fpmurphy View Post
Try the following:

Code:
sed -e "s|\(^ResourceDIR=\)\([0-9a-zA-Z\/\-]*$\)|\1${GR_RESOURCE_DIR}|" infile > outfile
Hi

This works for my first parameter ResourceDIR but not for the second one:
[root@skynet bianca]# cat aaaa
[Basic Configuration]
ResourceDIR=/app-nfs/meta/relay
MountFolderLive=/live/, /app-nfs/meta/live

For the second one /app-nfs/meta/live should be replaced with the read variable .

sed -e "s|\(^MountFolderLive=/live/,\)\([0-9a-zA-Z\/\-]*$\)|\1${GS_MOUNT_FOLDER_META}|" aaaa > bbbb

This doesn't work for this parameter.

Thanks,
Bianca
  #6 (permalink)  
Old 03-14-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
What is this "read variable"? Please give example of expected output.

Nobody can help you unless you are more precise with your requests for help.

Quote:
For the second one /app-nfs/meta/live should be replaced with the read variable .
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 09:12 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