From 0935cd21e4d1d880eb12038ac7ad9b57419c14b2 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 20 Nov 2022 18:50:45 +0100 Subject: [PATCH] shorthand -f+ for first number (+0) --- barcat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/barcat b/barcat index 5181143..d8deee4 100755 --- a/barcat +++ b/barcat @@ -20,7 +20,9 @@ GetOptions(\%opt, eval { local $_ = $_[1]; s/\A[0-9]+\z/(?:\\S*\\h+){$_}\\K/; - s/\A[+]([0-9]*)\z/(?:\\d+\\D+\\b){$1}\\K \\s* (?=\\d)/; + s{\A[+]([0-9]*)\z}{ + (!!$1 && '(?:\d+\D+\b){'.$1.'}\K') . '\s* (?=\d)' + }e; $opt{anchor} = qr/$_/; } or die $@ =~ s/(?:\ at\ \N+)?\Z/ for option $_[0]/r; }, @@ -605,7 +607,7 @@ Compare file sizes (with human-readable numbers): Same from formatted results, selecting the first numeric value: - tree -s --noreport | barcat -H -f+0 + tree -s --noreport | barcat -H -f+ Memory usage of user processes with long names truncated: -- 2.30.0