3

I have a file with the following format:

aaa@ bbb
bbb@ ccc& ddddd@ aaaf
ccc@ ddd& eee: abcd& dassda

The output should be:

aaaa@ bbb
bbb@ ccc&
ddddd@ aaaf
ccc@ ddd&
eee@ abcd& dassda

How would I be able to achieve this using AWK? I've tried sed and awk but I can only print a new line after the delimeter, I don't know how to print the whole thing on the next line.

1 Answer 1

8

sed :

sed 's/& /\&\n/' file

in case you need replace all & on the each string just add g after last /.

awk :

awk '{ sub(/& /,"&\n"); print }'

in case you need replace all & on the each string use gsub instead sub.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .