您能解释一下 bash 编程中反引号 (') 和单引号 (') 之间的区别吗?
答案1
pg@TREX:~/foo$ foo=date
pg@TREX:~/foo$ echo $foo
date
pg@TREX:~/foo$ echo `$foo`
Tue 21 Mar 2023 09:10:21 AM EET
pg@TREX:~/foo$ echo '$foo'
$foo
pg@TREX:~/foo$ echo "$foo"
date
pg@TREX:~/foo$ echo '`$foo`'
`$foo`
pg@TREX:~/foo$ echo "`$foo`"
Tue 21 Mar 2023 09:10:56 AM EET
pg@TREX:~/foo$ echo "\$foo"
$foo
pg@TREX:~/foo$ echo '\$foo'
\$foo
pg@TREX:~/foo$ echo `\$foo`
Tue 21 Mar 2023 09:12:26 AM EET
看: