bug#13786: pr command does not fold

2013-02-22 Thread Doh Smith
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.


bug#13786: pr command does not fold

2013-02-22 Thread Assaf Gordon
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






bug#13786: pr command does not fold

2013-02-22 Thread Pádraig Brady

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.