[plug] [PLUG] sed will not

Matt Kemner zombie at networx.net.au
Thu Oct 29 11:21:29 WST 1998

On Wed, 28 Oct 1998, Navarre wrote:

> I wished to perform a simple operation using sed to search for the
> string
> GAWK(1)^I
> tab and replace it with a form feed character, the string Gawk(1) and
> the tab character. 
> I tried using sed 's/GAWK(1)\11/\14Gawk(1)\11/' gawk.txt
> This did not match any lines in the file.

That's because you can't pass "nonprintable" characters to sed with
\number, because they have a special meaning for sed (for replacing bits
and pieces of the search string, ie:

echo foobarbazquux|sed 's,\(.*\)\(bar\)\(baz\)\(.*\),\1and\3,' outputs
"fooandbaz" :)

Unfortunately I don't know how one can pass "unprintable" characters to
sed - although \14 should correspond to ^N, so you ought to be able to
type "control-v control-n" to embed a ^N symbol

Be aware that ^N has a special meaning to the linux console - it will turn
all your lower case characters into graphical characters, which you can
only escape from by typing "echo control-v control-o" or if your terminal
is really screwed "echo control-V <esc> c" :) 
As David mentioned you can do the same with the tab character, just press
control-V and press tab to embed a tab.

Hope this helps

 - Matt

More information about the plug mailing list