How can I replace ; with ;\n (semicolon followed by a newline) in sed?
I’ve tried building off of
sed s/;/\\n/g file
and
sed -e '/;/G' file
but I can’t get either to work
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to cheat a bit: in
bashyou can sayor, portably (POSIX):
seddoes not portably/reliably handle backslash-escapes anywhere but in the pattern, and even there it’s limited (POSIX only requires that\nbe handled, not\tor the others). Note that you also need a backslash before the\nsoseddoesn’t read it as the end of the command.