I am on OSX and installed Homebrew to get the GNU coreutils. I wanted gsort
to be used instead of the preinstalled sort
command so I created a symlink to gsort
. My limited experience tells me that running sort
from the CL or in a script will use gsort
, however that's not what's happening:
$ which gsort; which sort
/usr/local/bin/gsort
/usr/local/bin/sort
$ ll /usr/local/bin/ | fgrep sort
1083450 lrwxr-xr-x 1 alex admin - 34B Mar 23 15:56:52 2016 gsort@ -> ../Cellar/coreutils/8.25/bin/gsort
1083466 lrwxr-xr-x 1 alex admin - 35B Mar 23 15:56:52 2016 gtsort@ -> ../Cellar/coreutils/8.25/bin/gtsort
1088327 lrwxr-xr-x 1 alex admin - 34B Mar 23 16:57:41 2016 sort@ -> ../Cellar/coreutils/8.25/bin/gsort
$ echo ${PATH}
/usr/local/opt/gnu-sed/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$ gsort --version | fgrep GNU
sort (GNU coreutils) 8.25
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
$ /usr/local/bin/sort --version | fgrep GNU
sort (GNU coreutils) 8.25
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
$ sort --version | fgrep GNU
sort (GNU coreutils) 5.93
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
Notice that when checking the version of gsort
and sort
(when using the absolute path to the symlink) it properly shows the newer coreutils version, but just running sort
still gives me the old, preinstalled version. Can anyone tell me why?
hash -d sort
? http://unix.stackexchange.com/a/5610/70524 – muru Mar 24 '16 at 15:56