我正要將最後一條命令存儲到一個變量中。linux:將最後一條命令存入變量
E.g:
#last command:
$> cp myfile /to/somewhere
$> last = #some magical command here
$> echo $last
cp myfile /to/somewhere
我試過!!:p
命令幾種方式,但它確實讓我最後的命令,但我不能把它存儲變量。
$> last=`!!:p`
$> echo $last
(empty)
任何幫助?
你爲什麼需要它? – choroba
[什麼是XY問題?](http://meta.stackexchange.com/q/66377) – Cyrus
我需要它編寫一個小腳本,將我的最後一個命令保存爲別名。 –