A csv file is being generated with a form feed (\f) character. This makes it hard to read in excel, etc.

How can I convert the form feed character into a newline (\n) character?

All my searches so far show how to replace control character with a literal character, not with another special character


1 Answer 1


With GNU sed:

sed 's/\f/\n/g' file

Other seds:

sed "$(printf 's/\f/\\\n/g')" file

Or with tr:

tr '\f' '\n' <file

With perl:

perl -pi -e 's/\f/\n/g' file

The -i is to overwrite the file in-place. For in-place editing with tr:

tr '\f' '\n' < file 1<> file

You must log in to answer this question.

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