I was wondering about single parentheses in bash. I know that they are used for executing commands in subshells and that they are used for creating arrays, but are they used for anything else?
One thing that caught my attention is that when you use the in variable assignment, like
var=(hello)
echo $var # hello
bash doesn't generate an error or anything, and the output is the same as if
var=hello
Are these two variable definitions the same or is there a difference?
var=(1 2 3); echo $var
is the same asvar=(1 2 3); echo ${var[0]}
? – Mattias Jul 23 '15 at 13:36bash
is the same. – jimmij Jul 23 '15 at 13:38""
inecho "${a}"
? – nn0p Feb 10 '19 at 14:42a
. Consider for examplea=*
, then tryecho $a
andecho "$a"
. – jimmij Feb 10 '19 at 14:52