Format output to a specific line length
Use fold
as follows:
fold -s -w80 file
This will only split at whitespace (-s
), using a line width of 80 characters (-w80
). So it does exactly the same as the fmt
solutions, but it also allows to break at any character when omitting the -s
option.
Use fmt
instead:
fmt --width=80 file
From man fmt
:
-w, --width=WIDTH
maximum line width (default of 75 columns)
Below mentioned solution might help:
cat file_name.txt | fmt -w 80 > reduced_file_name.txt
fmt - simple optimal text formatter.