How to wrap long lines in a text file on Linux?
Posted on In QAI have some text files which contain some long lines. Now I would like to break lines to at most 80 characters. How to wrap long lines in a text file on Linux?
The fold
command can wrap lines.
fold – wrap each input line to fit in specified width
For your purpose,
fold -w 80 -c in.txt > out.txt
fold has more options, you may check
-b, –bytes
count bytes rather than columns
-c, –characters
count characters rather than columns
-s, –spaces
break at spaces
-w, –width=WIDTH
use WIDTH columns instead of 80