replacing variable in sed command

From: kpakya (member46713_at_dbforums.com)
Date: 11/03/03

  • Next message: Barry Margolin: "Re: replacing variable in sed command"
    Date: Mon, 03 Nov 2003 17:52:59 -0500
    
    

    Can anyone tell me how do i substitute some shell variable in the search
    pattern of a sed command . e.g.

    for file in *tc

    do

     sed -n 's/^.*\($file\).*$//g' temp1 > temp2

    done

    i know the above wont work, but i have written it show my intention

    Here $file should be replaced by shell variable file

    thanks and regards

    kpakya

    --
    Posted via http://dbforums.com
    

  • Next message: Barry Margolin: "Re: replacing variable in sed command"

    Relevant Pages

    • Re: bash/echo/sed/date question (?)
      ... shell script. ... The sed command is used to dynamically create the ... replacement pattern more dynamic as a general exercise. ...
      (comp.unix.shell)
    • Re: [regex](vim) : substitute a pattern ,not part of a string
      ... >> in a code-file that is not part of a string. ... >> I want to substitute all b to d, ... The pattern is what i was looking for. ... Though the macro is very inspirational, ...
      (comp.editors)
    • Re: can sed pattern contain < & > characters or not?
      ... am trying with sed command like ... > found in pattern". ... his wife, Queen ChessBlindness? ...
      (comp.unix.shell)
    • Re: Shell script help
      ... > wrote Paul Schmehl thusly... ... >> of the port doesn't solve the problem of the formatting of the man ... >> Can someone explain what the sed command is doing? ... just deletes that pattern. ...
      (freebsd-questions)
    • sed substitution over different files
      ... I'd like to write a sed command which would: ... parse one file to find a pattern ... search in another file for the matched pattern ... P.S. and am I allowed to use single quotes to make it a shell command ...
      (comp.unix.shell)