HNS

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
LONG EXAMPLE
SYMLINKS
REPOSITORY
AUTHORS

NAME

hns - human numeric sort

SYNOPSIS

hns < input [> output]

hns < <(...) [> output]

... | hns [> output]

Note:
The name of the command varies — there are also hns+ and hxs. See SYMLINKS.

DESCRIPTION

A "human numeric" sorting program — does what sort -h is supposed to do!

(That is to say, it does what you likely already thought or may’ve assumed GNU/BSD sort -h does.)

OPTIONS

-h, --help
Print help information

-V, --version
Print version information

EXAMPLES

find . | hns

Numerically sort the names of the files in the current directory.

hns < <(dig peeweeharms.hk)

Numerically sort the IP addresses in the output of dig.

LONG EXAMPLE

1
seq 0 1000

|

xargs -I{} bash -c "echo {{}} > {}"

2
seq 0 1000

|

awk ’{printf "mv %s topsecret_%s.json\n", $0, $0}’

|

3
parallel

4
paste <(seq 0 1000) <(hns < <(echo topsecret_[[:digit:]]*.json))

|

awk ’{mv %s topsecret_%04d.json\n", $2, $1}’ | parallel

Use as part of a pipeline to fix accidentally unzeropadded numbers :-)

1

write some top secret JSON-format files as 0..=1000

2

move them to .json file extensions

3

oops! forgot to zeropad!! managing these files will suck now :-(

4

luckily we have hns!

SYMLINKS

When run as hns+, negative numbers are not considered. This is ever so slightly faster. When run as hxs, hexadecimal numbers are sorted appropriately (but "negative hexadecimals", a seemingly? useless concept, ignored).

REPOSITORY

https://github.com/ctrlcctrlv/humnumsort

AUTHORS

Fredrick Brennan, humnumsort Project Authors