Re: sed: variables in regular expression
From: Icarus Sparry (usenet_at_icarus.freeuk.com)
Date: 06/16/05
- Next message: William Park: "(patch for Bash) binary package"
- Previous message: Ed Morton: "Re: sed: variables in regular expression"
- In reply to: nasir: "sed: variables in regular expression"
- Next in thread: nasir: "Re: sed: variables in regular expression"
- Reply: nasir: "Re: sed: variables in regular expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 16 Jun 2005 19:30:14 GMT
On 2005-06-16, nasir <nasir.kamal@gmail.com> wrote:
> In my script instead of doing this:
> sed 's/nasir/NasirA/g' list.txt
>
> I want to use this:
> sed 's/$smallname/$uppername/g' list.txt
> where $smallname is "nasir" and $uppername is "NasirA".
>
> But sed is not taking variable names, and its output is the same as the
> original file although the file list.txt contains the string "nasir". I
> know it's easy for sed gurus.
This is a shell quoting problem. use double quotes if you want shell
variables to be recognised, rather than single quotes.
sed "s/$smallname/$uppername/g" list.txt
- Next message: William Park: "(patch for Bash) binary package"
- Previous message: Ed Morton: "Re: sed: variables in regular expression"
- In reply to: nasir: "sed: variables in regular expression"
- Next in thread: nasir: "Re: sed: variables in regular expression"
- Reply: nasir: "Re: sed: variables in regular expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|