GNU bug report logs -
#13786
pr command does not fold
Previous Next
Reported by: Doh Smith <doh.smith <at> gmail.com>
Date: Fri, 22 Feb 2013 17:13:01 UTC
Severity: normal
Tags: notabug
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 13786 <at> debbugs.gnu.org (full text, mbox):
Hello,
Doh Smith wrote, On 02/22/2013 05:14 AM:
> I could not get the pr command to fold the lines. Is this a bug?
> I am using pr (GNU coreutils) 8.13 under GNU bash 4.2.24.
I think 'pr' does the pagination and columnation, but doesn't actual re-folds (=wraps) lines to your desired length.
It is 'fmt' that can split long lines and join short lines.
>
> Here is an example - the following pr command produced an output that
> instead of folding a long line of text in the first column, it cuts it off:
>
> $ echo "Snow with areas of blowing snow. Low around 24. East wind around
> 15 mph, with gusts as high as 25 mph. Chance of precipitation is 100%.
> Total nighttime snow accumulation of 2 to 4 inches possible." | pr -F
> --columns=2
>
> 2013-02-22 04:08 Page 1
>
>
> Snow with areas of blowing snow. L
>
Example with pr and fmt:
========================
$ TEXT="Snow with areas of blowing snow. Low around 24. East wind around
15 mph, with gusts as high as 25 mph. Chance of precipitation is 100%.
Total nighttime snow accumulation of 2 to 4 inches possible."
##
## Re-fold into one column of 34 characters
##
$ echo "$TEXT" | fmt -w 34
Snow with areas of blowing snow.
Low around 24. East wind around 15
mph, with gusts as high as 25 mph.
Chance of precipitation is 100%.
Total nighttime snow accumulation
of 2 to 4 inches possible.
##
## Columnate the text
##
$ echo "$TEXT" | fmt -w 34 | pr -F --columns=2
2013-02-22 14:08 Page 1
Snow with areas of blowing snow. is 100%. Total nighttime snow
Low around 24. East wind around accumulation of 2 to 4 inches
15 mph, with gusts as high as possible.
25 mph. Chance of precipitation
=======
Notes:
1. 34 characters was chosen because the default page length of pr is 72 (and you want 2 columns + separator).
2. "pr -F" doesn't mean "fold", it means "use form-feed to separate pages" - just making sure you intended to use that.
HTH,
-gordon
This bug report was last modified 12 years and 94 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.