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: Arsen Arsenović
Subject: Re: [PATCH] fold: Add '-c' (cut) option to cut off lines at a specific WIDTH
Date: Sat, 11 Feb 2023 20:00:50 +0100

Hi Julian,

jhx <jhx0x00@gmail.com> writes:

> 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).

If I understood your intention and patch correctly, cut should already
do what you need:

  ~$ perl -e 'print "A" x 800, "\n";' | cut -c -50
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  ~$ perl -e 'print "A" x 8, "\n";' | cut -c -50 | cat --show-ends
  AAAAAAAA$

Check out ``(coreutils)cut invocation''.

> Attached you will find the patch for 'fold'.
>
> Apologies if there is something missing/wrong - Never contributed to any GNU
> software before. :)

Welcome!  Great having you.  :-D

> Greetings
>
> Julian "jhx"
>
> [2. text/x-patch; fold-cut-line.patch]...

Hope that helps!

Have a most wonderful day.
-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature


reply via email to

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