A rigor, a especificação POSIX para sed requer uma nova linha após a\ :
[1addr]a\ textWrite text to standard output as described previously.
Isso torna a escrita one-liner um pouco dolorosa, o que provavelmente é o motivo dos seguintes Extensão GNU para os comandos a , i e c :
As a GNU extension, if between the
aand the newline there is other than a whitespace-\sequence, then the text of this line, starting at the first non-whitespace character after thea, is taken as the first line of the text block. (This enables a simplification in scripting a one-line add.) This extension also works with theiandccommands.
Assim, para ser portável com a sua sintaxe sed , você precisará incluir uma nova linha após o a\ de alguma forma. A maneira mais fácil é simplesmente inserir uma nova linha entre aspas:
$ sed -e 'a\
> text'
(onde $ e > são prompts do shell). Se você achar que é um problema, bash [1] tem a $' ' sintaxe de cotação para inserir C- estilo escapa, então é só usar
sed -e 'a\'$'\n''text'
[1] e mksh (r39b +) e alguns shells não bash bourne (por exemplo, / bin / sh no FreeBSD 9 +)