2

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.

7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.