2

How to do sort -V in alpine linux?

sort: unrecognized option: V
BusyBox v1.28.4 (2018-12-06 15:13:21 UTC) multi-call binary.

Usage: sort [-nrugMcszbdfiokt] [-o FILE] [-k start[.offset][opts][,end[.offset][opts]] [-t CHAR] [FILE]...

Sort lines of text

    -o FILE Output to FILE
    -c  Check whether input is sorted
    -b  Ignore leading blanks
    -f  Ignore case
    -i  Ignore unprintable characters
    -d  Dictionary order (blank or alphanumeric only)
    -g  General numerical sort
    -M  Sort month
    -n  Sort numbers
    -t CHAR Field separator
    -k N[,M] Sort by Nth field
    -r  Reverse sort order
    -s  Stable (don't sort ties alphabetically)
    -u  Suppress duplicate lines
    -z  Lines are terminated by NUL, not newline
4

With Alpine, you can add GNU sort via the coreutils package:

apk add coreutils
0

In alpine, sort - V (version) is not supported.

Bear in mind that it's the busybox version and not the coreutis sort version.

Such is the price to pay to have a very light distribution.

Note that you can always add compiled binaries and glibc itself to alpine, or even static linked j binaries, but once you start doing that, you are adding more substantial size to it.

  • There is also posts about how to working around not having sort here, I am in my the tube now, cannot get links – Rui F Ribeiro Jan 29 at 10:09
  • I installed coreutils instead of out of the box one, and it works – Rex Lam Jan 30 at 1:12
  • Yeah, it works adding it, though I am no alpine user. The point is that coreutils is big. If you keep adding size to alpine, it comes to a point where it could make more sense using a cut down image of Debian., you can make 200-300 MB images of Debian, already with APT and security updates if you know what you are doing. – Rui F Ribeiro Jan 30 at 1:59
  • I know and agree what you say, the filesize of coreutils is not small for alpine but it is still acceptable for my use case as I'm not deploying it to an embedded device, thus, it would be a good balance for me :) – Rex Lam Jan 30 at 2:36
  • 1
    See related: unix.stackexchange.com/questions/419697/… ; however my concerns about Alpine is that once you lose that size advantage, it does not make sense keeping using it. (less supported, binaries built with musl instead of glibc, probably less updates during lesser time) – Rui F Ribeiro Jan 30 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.