Linux 移除 “-” 減號開頭的檔案或目錄

搞了很久都移除不了 “-” 減號( 負號 , hyphen , dash or minus ) ,就像是打不死的蟑螂一樣。

[root@liho ~]# rm -rf -139659725440768
rm: invalid option -- '1'
Try 'rm ./-139659725440768' to remove the file ‘-139659725440768’.
Try 'rm --help' for more information.

因為他把 -1 當作參數傳遞所以變成殺不死的目錄,所以要用 “–” 跳脫。

[root@liho ~]# rm -rf -- -139659725440768

這樣就可以了

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.