If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > removing specific pattern from given input

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-24-04, 11:25
deebee deebee is offline
Registered User
 
Join Date: Jul 2004
Posts: 45
removing specific pattern from given input

Input file contains :
1.$HOME/aaa.ksh , $HOME/bbb.ksh,$HOME/ccc.ksh, $HOME/cc.ksh, $SQL/mysql.sql, $BIN/mybin,$BIN/bina
2.$HOME/ddd.ksh, $HOME/ddff.ksh , $HOME/fffff.ksh, $HOME/ccccc.ksh, $SQL/qqq.sql, $BIN/mybin, $BIN/bina

If I need to remove $BIN/mybin from the above by using "$BIN/mybin" as a variable, how can I do it?

cat inputfile |sed 's/\$BIN\/mybin//g' works!!
but it doesnt work as cat inputfile |sed 's/\$var//g' where $var="\$BIN/mybin"
can someone help?
thanks
Reply With Quote
  #2 (permalink)  
Old 09-24-04, 11:30
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
Code:
#!/bin/ksh

file='deebee.txt'
var='$BIN/mybin'

sed -e "s!${var}!!g" $file
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 09-24-04, 11:44
deebee deebee is offline
Registered User
 
Join Date: Jul 2004
Posts: 45
Quote:
Originally Posted by vgersh99
Code:
#!/bin/ksh

file='deebee.txt'
var='$BIN/mybin'

sed -e "s!${var}!!g" $file
Excellent!! thanks!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On