Bash Difference between ${} and $()
Difference between ${} and $()
1, $(command) is “command substitution”. it runs the command, captures its output, and inserts that into the command line that contains the $(…);
eg:
$ ls -ld $(date +%B).txt
-rwxr-xr-x 1 Noob Noob 867 Jul 2 11:09 July.txt
$ echo $(date)
Thu Jul 2 16:33:11 SGT 2015
2, ${parameter} is “parameter substitution”.
The ${…} form,lets you get the value of a variable.
eg:
animal=cat
echo $animals
$ No such variable as “animals”.
echo ${animal}s
$ cats
echo $animal_food
$ No such variable as “animal_food”.
echo ${animal}_food
$ cat_food
猜你喜欢
转载自bonnietang.iteye.com/blog/2359821
今日推荐
周排行