Inserting newlines with AIX sed

The problem: A file needs to have newlines inserted at the end of a record. The current record delimiter is the word “END”. My version of sed doesn’t recognize inserting “n” or “r”.
Solution: Use sed and tr

sed -e 's/END/+/g' original.txt | tr "+" "n" > new.txt
The trick is making sure my orignial substitution {+} isn’t in the orignial file, easily checked by grep -c "+" original.txt

This entry was posted in computers/programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *