coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fold: Add '-c' (cut) option to cut off lines at a specific W


From: Michael Cook
Subject: Re: [PATCH] fold: Add '-c' (cut) option to cut off lines at a specific WIDTH
Date: Sat, 11 Feb 2023 11:14:03 -0500

FWIW, we can do that with sed.
Here's an example to crop at 50 chars (this example uses perl to generate
two lines of different lengths).

$ perl -le 'print "a" x 40; print "a" x 80' | sed -E 's/^(.{50}).+/\1.../'

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

On Sat, Feb 11, 2023 at 9:57 AM jhx <jhx0x00@gmail.com> wrote:

> Hello everyone,
>
> I personally often use 'fold' to break up some long lines, which works
> well. Lately I have been in the need to cut of a line at a specific
> length - removing the rest of the line. I made a small patch for 'fold'
> to do just that. The line gets cut off at WIDTH (specified via -w WIDTH)
> and three dots will be printed for a more appealing output. The new
> option added is '-c' for 'cut'.
> I checked out the newest code via Git and compiled 'fold' with the patch
> attached to this mail. (No errors/warnings were output).
>
> Attached you will find the patch for 'fold'.
>
> Apologies if there is something missing/wrong - Never contributed to any
> GNU software before. :)
>
> Greetings
>
> Julian "jhx"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]