Article 5A2V9 Any replacement for 'which' command?

Any replacement for 'which' command?

by
CVAlkan
from LinuxQuestions.org on (#5A2V9)
To see if some application (e.g. meld) is installed on a given system, the traditional method was to use Code:which meld and this would either return nothing or something akin to "/usr/bin/meld" and a shell script could continue doing its job based on the return.

While recently writing such a script, it became apparent that the "which" command returns nothing for a growing percentage of the software on many systems. So far as I can tell, it doesn't recognize (or even know about) things like AppImages, FlatPaks, Snaps and such.

A slightly more difficult approach would be Code:dpkg -l meld or even Code:apt-cache policy meld but those have the same failing.

The output of the command Code:sudo apt-cache search gimp for instance, like that of any app included in a distro, is probably useless, since this is not the same as "GIMP_AppImage-release-2.10.22-withplugins-x86_64.AppImage"

One could, I suppose, parse the various menu layout files, but there is no need or requirement for apps such as those mentioned to include themselves in the menus. Searching for a matching file with any "x" permission seemed as if it wouldn't be very efficient, and much care would need to be taken to determine that case-specific "GIMP_AppImage-release-2.10.22-withplugins-x86_64.AppImage" with an executable bit set is actually a match for the lower case "gimp" - not to mention that this file could be located pretty much anywhere - so before pursuing some ugly hack, I thought I would ask:

Given the growing prevalence of such all-in-one application packages, is there some newer utility around that addresses this?

The "which" command has been part of a standard Unix and Linux for at least 35 years (I even used it on Microsoft Xenix before Windows existed) so its usefulness is certainly not in question, but it seems as if it's no longer able to fulfil its purpose. Any thoughts?latest?d=yIl2AUoC8zA latest?i=0NRbr9tH1Uk:X_nY0dd5T90:F7zBnMy latest?i=0NRbr9tH1Uk:X_nY0dd5T90:V_sGLiP latest?d=qj6IDK7rITs latest?i=0NRbr9tH1Uk:X_nY0dd5T90:gIN9vFw0NRbr9tH1Uk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments