[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#28140: Here is a possible bug in documentation for 4.4
From: |
Assaf Gordon |
Subject: |
bug#28140: Here is a possible bug in documentation for 4.4 |
Date: |
Fri, 25 Aug 2017 09:42:32 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
Hello,
On 18/08/17 09:34 AM, bamber ward wrote:
> manual 4.4
> section 7-8
> sed -E ':x {N ; s/\n/ /g ; s/(.{40,40})/\1\n/ ; /\n/!bx ; P ;D}'
> does not work as described.
Thank you for reporting this.
Indeed, the sed program does not wrap the last line ('D' does not
provide a way to loop over the last line in case it's longer than 40
characters).
> #!/bin/sed -rf
> # line_wrap.sed (
>
> :x
> {
> N
> s/\n/ /g
> :y
> s_(.{40,40})_\1\n_
> /.{40,40}/ P
> s/.*\n//
> ty
> /\n/!bx
>
> }
I wonder if the following program would suffice
(very similar to yours, but without conditional P, just to simplify the
example code in the manual).
sed -E ':x
{
N
s/\n/ /g
:y
s/(.{20,20})/\1\n/
/\n/!bx
P
s/.*\n//
ty
}'
regards,
- assaf