GNU bug report logs - #13786
pr command does not fold

Previous Next

Package: coreutils;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13786 in the body.
You can then email your comments to 13786 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#13786; Package coreutils. (Fri, 22 Feb 2013 17:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Doh Smith <doh.smith <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 22 Feb 2013 17:13:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Doh Smith <doh.smith <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: pr command does not fold
Date: Fri, 22 Feb 2013 04:14:06 -0600
[Message part 1 (text/plain, inline)]
Hi,

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.

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

D.S.
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#13786; Package coreutils. (Fri, 22 Feb 2013 19:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 13786 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Doh Smith <doh.smith <at> gmail.com>
Cc: 13786 <at> debbugs.gnu.org
Subject: Re: bug#13786: pr command does not fold
Date: Fri, 22 Feb 2013 14:12:10 -0500
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





Information forwarded to bug-coreutils <at> gnu.org:
bug#13786; Package coreutils. (Fri, 22 Feb 2013 23:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 13786 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Doh Smith <doh.smith <at> gmail.com>
Cc: 13786 <at> debbugs.gnu.org
Subject: Re: bug#13786: pr command does not fold
Date: Fri, 22 Feb 2013 23:17:39 +0000
tag 13786 notabug
close 13786
stop

On 02/22/2013 10:14 AM, Doh Smith wrote:
> Hi,
>
> 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.
>
> 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

fold or fmt are used to wrap text.
It can then be passed on to pr for
further layout and truncation:
You can paste this command to a terminal for illustration:

for i in $(seq 22); do
  clear
  seq -f '%03.f' 1 $i |
  fmt -w20 |
  pr -t -c2 -w40 -s'|'
  sleep 1
done

thanks,
Pádraig.




Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Fri, 22 Feb 2013 23:20:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 13786 <at> debbugs.gnu.org and Doh Smith <doh.smith <at> gmail.com> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Fri, 22 Feb 2013 23:20:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 23 Mar 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 35 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.