2015年9月1日 星期二

mv, rm, touch 更動特殊名稱檔案( mv 減減 )

新增檔名 "--bear"的檔案
直接touch會報錯
$ touch --bear
touch: unrecognized option '--bear'
Try 'touch --help' for more information.
應使用
$ touch -- --bear

移動檔名"--bear"的檔案
直接mv會報錯
$ mv --bear __bear
mv: unrecognized option '--bear'
Try 'mv --help' for more information.
應使用
$ mv -- --bear __bear

刪除檔名"--bear"的檔案
直接rm會報錯
$ rm --bear
rm: unrecognized option '--bear'
Try 'rm ./--bear' to remove the file ‘--bear’.
Try 'rm --help' for more information.
應使用
$ rm -- --bear


參考資料:
http://superuser.com/questions/361573/mv-command-confuses-directory-name-with-command-option  mv command confuses directory name with command option


沒有留言:

張貼留言