使用find刪除包含特殊字符文件

文件名如下:

8_140_3g:~ #ll
-rw-r--r-- 1 admin root 0 2011-11-29 23:18:41 --header=Host: 172.16.8.166

直接用rm,刪除失敗

8_140_3g:~ #rm --header\=Host\:\ 172.16.8.166 
rm: unrecognized option `--header=Host: 172.16.8.166'
Try `rm ./'--header=Host: 172.16.8.166'' to remove the file `--header=Host: 172.16.8.166'.
Try `rm --help' for more information.
8_140_3g:~ #


用for循環,刪除失敗:

8_140_3g:~ #for f in `ls \-*`;do echo $f;done
/bin/ls: unrecognized option `--header=Host: 172.16.8.166'
Try `/bin/ls --help' for more information.
8_140_3g:~ #


用ls顯示,失敗:

8_140_3g:~ #ll '--header=Host: 172.16.8.166'
/bin/ls: unrecognized option `--header=Host: 172.16.8.166'
Try `/bin/ls --help' for more information.
8_140_3g:~ #


用find命令,顯示成功:

8_140_3g:~ #find . -name "*Host*"
./--header=Host: 172.16.8.166
8_140_3g:~ #


用find命令,刪除成功:

8_140_3g:~ #find . -name "*Host*" -exec rm {} \;
8_140_3g:~ #
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章