Linux/PATH

From Omnia
Jump to navigation Jump to search

Show PATH

echo $PATH

Find the Full Path of a Specific Binary

which [command]

Example:

which grep

Search PATH

List All Available Binaries/Commands

compgen -c | sort

Advanced Method (for Full Paths) - If you need the full path to all executables in your PATH, you can use a loop or a more complex find command. A robust method is to use find within the directories specified by $PATH:

#  IFS=:;: Temporarily sets the internal field separator to a colon, which helps the shell correctly interpret the $PATH variable's structure.
IFS=:; find $PATH -maxdepth 1 -executable -type f 2>/dev/null | sort

keywords