Unfortunately the virtual machine that is sed
works a certain way, and the way that it works doesn’t make it easy to:
-
replace newlines. See How can I replace a newline (\n) using sed? for why that is.
-
replace anything with a tab, See Replacing / with TAB using sed for more about that.
Still, it can be done:
printf 'foo]\nbar\n' | sed ':a;N;$!ba;s/\]\n/ \'$'\t/g'
Output:
foo bar