Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    45

    Unanswered: 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

  2. #2
    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> |
    +-----------------------+

  3. #3
    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!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •