File exists in $PATH

is there a way to do this (for linux):

exist file "shuf" of folder "$PATH"

So this would be to get the file if it exists in any of the folders in the $PATH environment variable?

This should provide all of the folders of the PATH env var: (should be universal for all OSes) https://bigfix.me/relevance/details/3003684

(folders it) of unique values of (it as trimmed string) of substrings separated by (";";":") of values of (variables "PATH" of it; (if (windows of operating system) then (x64 variables "PATH" of it) else NOTHINGS) ) of environments

This is all files in PATH:

files of (folders it) of unique values of (it as trimmed string) of substrings separated by (";";":") of values of (variables "PATH" of it; (if (windows of operating system) then (x64 variables "PATH" of it) else NOTHINGS) ) of environments

This should be what you are looking for:

exists files "shuf" of (folders it) of unique values of (it as trimmed string) of substrings separated by (";";":") of values of (variables "PATH" of it; (if (windows of operating system) then (x64 variables "PATH" of it) else NOTHINGS) ) of environments

Reference: https://support.bigfix.com/inspectors/Environment%20Objects_Any.html

1 Like

sweeeet!

However I do question the need for all of the extra “windows of operating system” stuff. The below syntax works for me on linux looking for shuf, or cmd.exe on windows:

exists files "cmd.exe" of (folders it) of unique values of (it as trimmed string) of substrings separated by (";";":") of values of variables "PATH" of it of environments

I’m not sure if there is a difference between variables pulled from 32 or 64 bit OS. Could be wrong though.

I designed the relevance to work on ALL OSes and to pull all PATH environment variables.

variables of environments will work on any OS, while x64 variables of environments only works on windows.

You are correct that the relevance without x64 variables of environments will work just fine on all non-windows systems, but it won’t hurt to have that included just so that this relevance can be universal.

Even on Windows the variables and x64 variables should be mostly the same, but it is possible there could be a difference, which is why I included both. The unique values in the relevance will collapse any duplication.

1 Like