Just a thought on sed

Marc Heerdink marc at linuxfromscratch.org
Mon May 6 06:38:25 PDT 2002


Op ma 06-05-2002, om 15:21 schreef Phil Gendreau:
[..]
> Not sure I get it...
> What fails?

Nothing.

Suppose we have the sed command posted in an earlier post:

echo "$(sed 's/foo/bar/g' file)" > file

File "file" contains this:

-------------------------
ablsabfldsg sdsd gsd gasdrngaseg; foo
asdfsln foo safnsldkng bar foo bar fass
-------------------------

Running the sed would produce this:

-------------------------
ablsabfldsg sdsd gsd gasdrngaseg; bar
asdfsln bar safnsldkng bar bar bar fass
-------------------------

Now suppose "file" contains the output of a make command:

-------------------------
make: Entering directory `/home/gimli/src'
make: *** No targets specified and no makefile found.  Stop.
make: Leaving directory `/home/gimli/src'
-------------------------

It contains backticks, normal quotes etc etc. Running

echo "$(sed 's/gimli/root/g' file)" > file

produces:

-------------------------
make: Entering directory `/home/root/src'
make: *** No targets specified and no makefile found.  Stop.
make: Leaving directory `/home/root/src'
-------------------------

So there's nothing to worry about, Nicholas might be using an old sed...
The echo "$(sed 's///' file)" >file command looks so obfuscated though
that a simple backup, sed the backup to the original is still the better
solution.

Please post replies to lfs-chat.

-- 
         (__)
         (oo)
   /------\/
  / |    ||         ..."Have you mooed today?"...
 *  /\---/\   Marc Heerdink <marc at linuxfromscratch.org>
    ~~   ~~

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list