sed question??

Cameron Simpson cs at zip.com.au
Sun Jun 7 02:23:47 UTC 2015


On 06Jun2015 21:53, bruce <badouglas at gmail.com> wrote:
>Evening..

Morning...

>As a test, the following is an attempt to replace "text" from a test
>file with "text" from an external file.
>
>aa=$(cat www1.txt)

BTW, this can be written:

  aa=$(< www1.txt)

>sed -i "s*#\tISSUES/NOTES::*$aa*g" foo.py1
>
>When I check the foo.py1 file, I get "$aa" in the file, instead of the
>replacement text.

Are you sure you used the exact command above? If you have used single quote I 
would have expected such a result, but not with double quotes.

>The test is using replacement delimeters for the sed, as the
>replacement text has slashes...

I'm fond of ^G for this purpose:-)

>thanks for any pointers.

When debugging sed scripts and other fiddly shell commands it is often useful 
to trace the actual executed command, thus:

  ( set -x; sed -i "s*#\tISSUES/NOTES::*$aa*g" foo.py1 )

which will should the issued sed command, after the shell has done its 
mangling.

Cheers,
Cameron Simpson <cs at zip.com.au>


More information about the users mailing list