The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ftp username with back slash sam99 Shell Programming and Scripting 1 04-29-2008 06:19 AM
awk slash McLan Shell Programming and Scripting 6 04-09-2008 11:00 AM
grep for forward slash wxornot Shell Programming and Scripting 3 02-29-2008 07:01 PM
Globbing slash Wildcarding Question scotbuff Shell Programming and Scripting 4 02-01-2007 09:10 PM
touching a file which contains slash char axes High Level Programming 1 09-25-2006 02:54 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-28-2007
Registered User
 

Join Date: May 2002
Posts: 62
Help with SED and forward slash

Using the script: (Called replaceit)

#!/bin/ksh

String=$1
Replace=$2

sed -e "s/${orig}/${new}/g" oldfile.txt > newfile.txt

In oldfile.txt, I'm looking for: getenv("Work")
And change it To: /u/web

I execute the script:
replaceit "getenv(\""Work\"")" /u/web

I'm getting sed command garbled. I know it has something to
do with the slashes in /u/web

Can someone lead me in the right direction?
Reply With Quote
Forum Sponsor
  #2  
Old 12-28-2007
Resident BOFH
 

Join Date: Dec 2007
Posts: 262
what happens if you change your sed statement to

Code:
sed -e "s!${orig}!${new}!g" oldfile.txt > newfile.txt
Reply With Quote
  #3  
Old 12-28-2007
Registered User
 

Join Date: May 2002
Posts: 62
Quote:
Originally Posted by frank_rizzo View Post
what happens if you change your sed statement to

Code:
sed -e "s!${orig}!${new}!g" oldfile.txt > newfile.txt
Works beautifully, thanks!
Reply With Quote
  #4  
Old 05-26-2008
Registered User
 

Join Date: May 2008
Posts: 1
nice. tks a lot!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0