2
コマンドの出力をシェル変数に割り当てるにはどうすればよいですか?
式の結果を変数に割り当て、それを文字列と連結してからエコーします。ここに私が持っているものがあります: #!/bin/bash cd ~/Desktop; thefile= ls -t -U | grep -m 1 "Screen Shot"; echo "Most recent screenshot is: "$thefile; しかし、その出力: Screen Shot 2011-07-03 at 1.55.43 PM.png Most recent screenshot is: したがって、それはに割り当てられておらず$thefile、実行時に印刷されているように見えます。