SLUG Mailing List Archives
Re: [SLUG] sed question
- To: unauthorized@xxxxxxxxxxxx
- Subject: Re: [SLUG] sed question
- From: Peter Chubb <peter@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 2 Apr 2006 18:59:03 +1000
- Cc: slug@xxxxxxxxxxx
- Comments: Hyperbole mail buttons accepted, v04.18.
>>>>> "unauthorized" == unauthorized <unauthorized@xxxxxxxxxxxx> writes:
unauthorized> On Sun, 2 Apr 2006 17:31:33 +1000 Peter Chubb
unauthorized> <peter@xxxxxxxxxxxxxxxxxx> wrote:
>> >>>>> "Simon" == Simon Bowden <simonb@xxxxxxxxxxxxxxx> writes:
Simon> On Fri, 31 Mar 2006, Steven Heimann wrote:
>> >> **1. Scope**
>> >> I wrote the following
>> >> sed -i.bak "s/^\(\*\*[0-9][. ]\)\*\*\(.*\)$/\1\2**/" *.txt
>> The $ will be interpreted by the shell, because it's in double
>> quotes. Depending on what shell you're using the backslashes could
>> also be swallowed. You need to use single quotes for most shells.
unauthorized> I know this might be off topic a bit but... I would
unauthorized> definitely say it depends on your shell as to whether or
unauthorized> not the "$" will be interpreted.
In this particular case it's OK, because the character following the $
isn't part of a valid shell variable. In the general case, I'd always
quote dollar signs if they're in a double quoted string, just to be
As another poster mentioned, the problem that Steven was having was
caused by the ambiguity of line ending when there are carriage returns
as well as line feeds in the file.
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia