From: paulcol@andor.dropbear.id.au
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] how to word-wrap using a pipe?
Date: Mon, 20 Oct 2008 14:19:31 +1100 [thread overview]
Message-ID: <20081020031931.GA25434@andor.dropbear.id.au> (raw)
In-Reply-To: <48FBDB4A.9070109@realss.com>
On Mon, Oct 20, 2008 at 09:13:46AM +0800, zhangweiwu@realss.com 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
next prev parent reply other threads:[~2008-10-20 3:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-20 1:13 [gentoo-user] how to word-wrap using a pipe? zhangweiwu
2008-10-20 2:30 ` meino.cramer
2008-10-20 3:19 ` paulcol [this message]
2008-10-21 11:01 ` Neil Bothwick
-- strict thread matches above, loose matches on Subject: below --
2008-10-20 3:38 djanderson
[not found] <boRBg-I6-9@gated-at.bofh.it>
[not found] ` <boTD6-3il-5@gated-at.bofh.it>
[not found] ` <bpnhS-7Pt-33@gated-at.bofh.it>
2008-10-22 13:41 ` zhangweiwu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081020031931.GA25434@andor.dropbear.id.au \
--to=paulcol@andor.dropbear.id.au \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox