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')
--
Real Softservice
Huateng Tower, Unit 1788
Jia 302 3rd area of Jinsong, Chao Yang
...just a shot in the dark: Try 'fmt' (UNIX standard too so no extra
install I think).
Kind regards,
Meino Cramer
zhangweiwu@realss.com <zhangweiwu@realss.com> [08-10-20 03:52]:
> 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')
>
> --
> Real Softservice
>
> Huateng Tower, Unit 1788
> Jia 302 3rd area of Jinsong, Chao Yang
>
> Tel: +86 (10) 8773 0650 ext 603
> Mobile: 159 1111 7382
> http://www.realss.com
>
>
--
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.
10-20-2008, 03:19 AM
how to word-wrap using a pipe?
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
10-20-2008, 03:19 AM
how to word-wrap using a pipe?
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
10-20-2008, 03:38 AM
djanderson
how to word-wrap using a pipe?
Zhang Weiwu 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 think you'll find what you're looking for in the 'fmt' standard unix
command. `man fmt', it's part of coreutils.
-Doug
--
View this message in context: http://www.nabble.com/how-to-word-wrap-using-a-pipe--tp20061899p20062130.html
Sent from the gentoo-user mailing list archive at Nabble.com.
10-21-2008, 11:01 AM
Neil Bothwick
how to word-wrap using a pipe?
On Mon, 20 Oct 2008 14:19:31 +1100, paulcol@andor.dropbear.id.au wrote:
> Hmm, 'fold' looks promising...
I've been using this one for years and it does exactly what it says.
--
Neil Bothwick
Used Iraqi rifles for sale: Dropped once, never fired...
10-22-2008, 01:41 PM
how to word-wrap using a pipe?
Neil Bothwick wrote:
> On Mon, 20 Oct 2008 14:19:31 +1100, paulcol@andor.dropbear.id.au wrote:
>
>> Hmm, 'fold' looks promising...
>
> I've been using this one for years and it does exactly what it says.
>
>
Great thanks for all the answers. fmt and fold both enlightened me.
--
Real Softservice
Huateng Tower, Unit 1788
Jia 302 3rd area of Jinsong, Chao Yang