Is there an equivalent to
ls -v in Mac OS X that will do version number sorting?
In Mac OS X,
ls -v does NOT do version number sorting, but the Finder seems to.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
ls in OS X does not have version sort capabilities. This is a feature of GNU
ls, which comes with most Linuxes, but does not ship with OS X. You can install GNU
ls through the GNU coreutils package.
So, for example, install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
Wait a bit, read the installation instructions. Then, install coreutils:
brew install coreutils
This will add all the GNU coreutils with the
g prefix, so for example, you will be able to use
gls instead of
ls, which now offers version sort.
To override the default
ls behavior (and those of other builtins), you can add this line to your
Note that this might affect other programs that rely upon the BSD version. If you just want to alias
ls, use the following instead:
bash script for sorting version numbers correctly on mac terminal