1

Right now, if I type whereis on an executable that I'm interested in knowing the location, I get back several results where this software is located. What configuration can be done to get the last result at the front of the list?

If I'm running whereis gcc, I may have 5 different versions of gcc on the OS, but the highest/most-recent version displays last in the results of whereis gcc, so it's not the preferred version of gcc. So even though I have version 7.1 of GCC, running gcc -v displays the lowest version that's installed on my box.

1 Answer 1

1

whereis python | sed 's/ /\n/g' | sort | uniq

Then sort has many options

If you want to reverse the order:

whereis python | sed 's/ /\n/g' | sort -r | uniq

-r, --reverse
    reverse the result of comparisons

if you (could) have some odd binary/source/manual files containing special chars:

-i, --ignore-nonprinting
    consider only printable characters
1
  • 1
    Also, sort | uniq can be replaced with sort -u Jul 17, 2017 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .