[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61267: shuf -i with negative numbers
From: |
Pádraig Brady |
Subject: |
bug#61267: shuf -i with negative numbers |
Date: |
Sat, 4 Feb 2023 12:09:25 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Thunderbird/109.0 |
tag 61267 notabug
close 61267
stop
comments below...
On 03/02/2023 22:31, kpm@plan9.lol wrote:
hello
shuf -i option cannot handle negative numbers.
examples:
$ shuf -i -10-20
$ shuf -i 0--20
don't know if it's a bug or a feature.
The input range needs to be unsigned
as documented in the info manual.
It should be easy enough to shift to the desired range,
for example:
$ shiftn() { sed "s/\$/$1/" | bc; }
$ shuf -i 0-10 | shiftn -5
3
-2
0
5
2
-5
4
-1
-3
1
-4
cheers,
Pádraig