On 2023-08-22, kasak <ka...@kasakoff.net> wrote: > Hello misc! > > I'm in trouble with sed! > > I need to insert tab in some places, but no luck :( > > in linux it works: > > [kasak@kasakoff ~]$ echo 'one two three' | sed s/two/\\ttwo/ > one two three > > in OpenBSD it just add t: > > kasak@OpenBSD:~$ echo 'one two three' | sed s/two/\\ttwo/ > one ttwo three
\t in the replacement string is not portable, it's an extension in GNU sed (https://www.gnu.org/software/sed/manual/html_node/Escapes.html). alternatives: echo 'one two three' | sed -e "s/two/`printf '\t'`two/" echo 'one two three' | perl -p -e s/two/\\ttwo/ or you can use a literal tab character, typed in many shells with ^V tab: echo 'one two three' | sed 's/two/ two/'