[CentOS] sed append question

Wed Aug 19 17:47:37 UTC 2009
Filipe Brandenburger <filbranden at gmail.com>

Hi,

On Wed, Aug 19, 2009 at 13:24, Joseph L.
Casale<JCasale at activenetwerx.com> wrote:
> Hey guys,
> I am trying to make sed append every line containing a string with another line.
> problem is the appended line needs to start with a tab:
> # sed -i '/string/a \tstuff\t\t\tmorestuff' file
> Obviously \t or \x09 etc doesn't get interpreted unless there are other characters
> before it? How can I get this to begin with a <tab>?

Hi,

The "a" command expects to be followed by a "\", so it's eating the
one in your first "\t". If you add another "\" it seems to work as you
want it to:

$ echo string | sed '/string/a \\tstuff\t\t\tmorestuff'
string
        stuff                   morestuff
$

HTH,
Filipe