What is the proper way to insert tab in sed? I'm inserting a header line into a stream using sed. I could probably do a replacement of some character afterward to put in tab using regular expression, but is there a better way to do it?
For example, let's say I have:
some_command | sed '1itextTABtext'
You can simply use the
i command correctly:
some_command | sed '1i\ text text2'
where, as I hope it is obvious, there is a tab between 'text' and 'text2'. On MacOS X (10.7.2), and therefore probably on other BSD-based platforms, I was able to use:
some_command | sed '1i\ text\ttext2'
sed translated the
\t into a tab.
sed won't interpret
\t and inserting tabs at the command line is a problem, create a shell script with an editor and run that script.