将 echo 的结果存储在一个没有 运行 的变量中
Store result of echo in a variable without running it
我正在尝试创建一个名为 $SPIM
的变量来保存 which spim
的结果,但它运行的是 spim
,这不是我的本意。
➜ 10 git:(main) ✗ echo "$(which spim)"
/usr/bin/spim
➜ 10 git:(main) ✗ $SPIM=$(echo "$(which spim)")
SPIM Version 8.0 of January 8, 2010
Copyright 1990-2010, James R. Larus.
All Rights Reserved.
See the file README for a full copyright notice.
Loaded: /usr/lib/spim/exceptions.s
(spim) exit
在这里使用 bash
运行没有问题(我没有安装 spim
)。
无需再次 echo
。
$ SPIM=$(which ls)
$ echo $SPIM
/usr/bin/ls
我正在尝试创建一个名为 $SPIM
的变量来保存 which spim
的结果,但它运行的是 spim
,这不是我的本意。
➜ 10 git:(main) ✗ echo "$(which spim)"
/usr/bin/spim
➜ 10 git:(main) ✗ $SPIM=$(echo "$(which spim)")
SPIM Version 8.0 of January 8, 2010
Copyright 1990-2010, James R. Larus.
All Rights Reserved.
See the file README for a full copyright notice.
Loaded: /usr/lib/spim/exceptions.s
(spim) exit
在这里使用 bash
运行没有问题(我没有安装 spim
)。
无需再次 echo
。
$ SPIM=$(which ls)
$ echo $SPIM
/usr/bin/ls