On Mon, Oct 20, 2008 at 09:13:46AM +0800, [EMAIL PROTECTED] wrote:
> Hello. How can I line-wrap a text file that was not wrapped before (e.g.
> like text file created on Microsoft Windows's notepad, the software does
> softwrap by default, thus the file created using it often have very long
> text lines) by using command pipe?
>
> I could use vim, activate some formatting options and use gq. But that
> couldn't be used on a pipe.
>
> I could use groff, but that command line looks too complicated:
>
> $ head -n1 max_payne | groff -Tutf8 | grep --invert-match ^$
> Life was good. A house on the Jersey side across the river. The
> smell of freshly cut lawns. The sounds of children playing. A
> beautiful wife and a baby girl. The American dream come true. But
> dreams have a nasty habit of going bad when you’re not looking.
>
>
> Besides groff wraps not according to the console term width, but
> according to the paper size in /etc/paper. It would be nice to have
> something wrap my text by using console width (what you get with '$ stty
> -a | head -n1')
$ man -k wrap | fgrep line
Text::Wrap (3pm) - line wrapping to form simple paragraphs
fold (1) - wrap each input line to fit in specified width
ggz-wrapper (6) - GGZ Gaming Zone command line core client
Hmm, 'fold' looks promising...
$ fold --help
Usage: fold [OPTION]... [FILE]...
Wrap input lines in each FILE (standard input by default), writing to
standard output.
Mandatory arguments to long options are mandatory for short options too.
-b, --bytes count bytes rather than columns
-s, --spaces break at spaces
-w, --width=WIDTH use WIDTH columns instead of 80
--help display this help and exit
--version output version information and exit
--
Reverend Paul Colquhoun, ULC. http://andor.dropbear.id.au/~paulcol
Asking for technical help in newsgroups? Read this first:
http://catb.org/~esr/faqs/smart-questions.html#intro