Bash - $ PATH and $ {PATH}

What is the difference between using an environment variable like PATH like $ PATH or $ {PATH}?

+3
source share
3 answers

In most cases there is no difference. The only thing that matters is if you want to include back text after the extension. For example, suppose yours PATHcontains a string FOO(actually not a valid path, but this is an example), and you would like to create a string FOOBAR. If you did

$PATHBAR

You will get a variable extension with a name PATHBARthat is probably not the way you wanted. If you did

$PATH BAR

FOO BAR, , . :

${PATH}BAR

FOOBAR.

+12

PATH - , $PATH ${PATH} - . ${PATH} , echo ${PATH}b, $PATHb. , bash , .

+4

In your case there is no difference, but - take the situation: you have two variables:

$FOO = "YA"
$YADA = "bar"

then ${$FOODA}it won’t give you anything until it ${${FOO}DA}gives you a bar

0
source

Source: https://habr.com/ru/post/1717532/


All Articles