Vijay Vijay - 3 months ago 15
Bash Question

How to replace newlines with tab characters?

I have pattern like below

hi
hello
hallo
greetings
salutations
no more hello for you


I am trying to replace all newlines with tab using the following command

sed -e "s_/\n_/\t_g"


but it's not working.

Could anybody please help? I'm looking for a solution in sed/awk.

Answer Source

not sure about output you want

# awk -vRS="\n" -vORS="\t" '1' file
hi      hello   hallo   greetings       salutations     no more hello for you