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
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 05:28 PM
How to replace variable inside the variable mani_um Shell Programming and Scripting 31 08-09-2007 07:56 PM
Replace variable with a user defined variable ce124 Shell Programming and Scripting 1 04-15-2007 11:56 AM
Export command giving Variable Name vs the Value set for the Variable ParNone UNIX for Dummies Questions & Answers 2 04-03-2006 08:43 AM
ksh: A part of variable A's name is inside of variable B, how to update A? pa3be Shell Programming and Scripting 4 03-30-2005 08:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 09-27-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Any character (other than backslash or newline) can be used instead of a slash to delimit the regular expression and the replacement.
Code:
sed -e "s:?:$ORACLE_HOME:g" $file_name
Reply With Quote
Forum Sponsor
  #9  
Old 09-27-2005
Registered User
 

Join Date: May 2005
Posts: 54
Thumbs up

Thanks very much. Its resolved.
Reply With Quote
  #10  
Old 05-06-2008
Registered User
 

Join Date: May 2008
Posts: 2
What if I delete?

Quote:
Originally Posted by Ygor View Post
Any character (other than backslash or newline) can be used instead of a slash to delimit the regular expression and the replacement.
Code:
sed -e "s:?:$ORACLE_HOME:g" $file_name
But that rule doesn't work when I try to delete a line. Like following code doesn't work:
Code:
sed ":$ORACLE_HOME: d" $file_name
Simply following works alright
Code:
sed '/text/ d' $filename
but not this
Code:
sed ':text: d' $filename
So how do I delete a line using variables that contain slashes?
Reply With Quote
  #11  
Old 05-06-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
You can use any delimiter in the search string too, but you have to backslash it (don't ask me why).

Code:
sed '\:text:d' $filename
Reply With Quote
  #12  
Old 05-06-2008
Registered User
 

Join Date: May 2008
Posts: 2
Thank you era for fast reply. And that works!
Thanks again.
Reply With Quote
  #13  
Old 05-07-2008
Registered User
 

Join Date: May 2008
Posts: 2
Quote:
Originally Posted by universe View Post
But that rule doesn't work when I try to delete a line. Like following code doesn't work:
Code:
sed ":$ORACLE_HOME: d" $file_name
Simply following works alright
Code:
sed '/text/ d' $filename
but not this
Code:
sed ':text: d' $filename
So how do I delete a line using variables that contain slashes?
hgfhgfhgfhgfhghhgf
Reply With Quote
  #14  
Old 05-07-2008
Registered User
 

Join Date: May 2008
Posts: 2
how to delete line from file ( using variables)



hi i have a big file i need every time to cut number of lines related together and ta delete also first two lines in the file.

for example :
while ( $x <= $n)
set var1 = ` cat file | sed '1,2d' | awk '{print $4}' | sed '$x,$d' `
@ x = $x + $t
end

it gives me an error with sed command which contains the variable ??????

can anyone help me!!!!!!!!!!!!!!!!!!!!
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 05:52 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