How To Read / Print $PATH Shell Variable

How To Read / Print $PATH Shell Variable

The $PATH shell variable is a list of directories that the shell searches for executables when you run a command. To read or print the $PATH variable, you can use the echo command and the $PATH variable.

Here is an example of how to print the $PATH variable in the Bash shell:

echo $PATH
So‮cru‬e:www.lautturi.com

This will print the $PATH variable to the terminal, with the directories separated by a colon (:). For example:

/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

You can also use the echo command to print specific directories in the $PATH variable. For example, to print only the first directory in the $PATH variable, you can use the cut command to split the $PATH variable and print the first field:

echo $PATH | cut -d: -f1

This will print the first directory in the $PATH variable, for example:

/usr/local/bin
Created Time:2017-10-28 21:38:53  Author:lautturi