我想将表达式的结果(即命令的输出)分配给一个变量,然后对其进行操作——例如,将它与一个字符串连接起来,然后回显它。这是我所拥有的:
#!/bin/bash
cd ~/Desktop;
thefile= ls -t -U | grep -m 1 "Screen Shot";
echo "Most recent screenshot is: "$thefile;
Run Code Online (Sandbox Code Playgroud)
但是输出:
Screen Shot 2011-07-03 at 1.55.43 PM.png
Most recent screenshot is:
Run Code Online (Sandbox Code Playgroud)
因此,它看起来没有分配给$thefile
,并且在执行时正在打印。
我错过了什么?