誤改檔名後如何快速改回來 - Linux

Table of Contents

有時候手殘會發生這種事

原本想要打這樣:

user@local_host:~$ scp a_file_with_long_filename user@remote_host:path_to_put_the_file

卻不小心打成這樣, 誤改了檔名:

user@local_host:~$ mv a_file_with_long_filename user@remote_host:path_to_put_the_file

於是只好先把檔名改回來再scp:

user@local_host:~$ mv user@remote_host:path_to_put_the_file a_file_with_long_filename

user@local_host:~$ scp a_file_with_long_filename user@remote_host:path_to_put_the_file

像這種情況就算有tab completion的幫忙也是略嫌麻煩

以上情境只是舉例 也有其他情況也是不小心改了檔名

想請問的是像這種情況有沒有辦法:

1. 用更短的指令把檔名改回來

or

2. 把"改檔名"和"重作動作"兩個動作變成一個動作, 而且指令不會太長?

--

All Comments

Leila avatarLeila2011-09-20
我第一個想到的是把mv alias 成 mv -i 可以解決大部分的問題
Zenobia avatarZenobia2011-09-22
但是剛剛試了一下\mv -i 似乎不會 interactive? Ubuntu 11.04
Suhail Hany avatarSuhail Hany2011-09-25
-i似乎是在複寫的時候才會interactive?
Necoo avatarNecoo2011-09-28
ya, 我腦補interactive了
Margaret avatarMargaret2011-10-01
mv !:2 !:^
Ivy avatarIvy2011-10-05
在X下嗎?? 用滑鼠選取後按中鍵再搭ctrl-w ctrl-a
Irma avatarIrma2011-10-06
try: mv a b => mv !:2 !:^
Hedwig avatarHedwig2011-10-11
mv (alt+.) !:^ 也可以(alt+.是上個指令最後一個arg)
Ingrid avatarIngrid2011-10-12
set -o vi 可以把commandline設為vim 你說的功能大概就有
不過我想應該不多人用這種模式就是了
Aaliyah avatarAaliyah2011-10-16
有vim裡面的y複製d剪下功能