2011-11-27 92 views
3

我的LAMP Web服務器呈現備份文件像這樣:在網絡服務器上備份文件!和〜

  • !index.php
  • !~index.php
  • bak.index.php
  • Copy%20of%20index.php

我試着用rm刪除,但它無法找到文件。

這是否與bash或vim有關?這怎麼解決?

+0

當您嘗試刪除文件時,您的錯誤消息是什麼? –

回答

2

轉義字符(用反斜槓)像這樣:

[ 09:55 [email protected] ~/t ]$ ll 
total 0 
-rw-r--r-- 1 jon people 0 Nov 27 09:55 !abc.html 
-rw-r--r-- 1 jon people 0 Nov 27 09:55 ~qwerty.php 
[ 09:55 [email protected] ~/t ]$ rm -v \!abc.html \~qwerty.php 
removed '!abc.html' 
removed '~qwerty.php' 
[ 09:56 [email protected] ~/t ]$ ll 
total 0 
[ 09:56 [email protected] ~/t ]$ 
+0

運行rm -v \!index.php時沒有提供這樣的文件。它看起來像文件不存在,因爲[find/-name \!index.php]不返回任何內容,並使用die()命令更新/index.php,而瀏覽器中的/!index.php顯示更新index.php文件。你認爲這可能是捷徑嗎? – steve76

+0

發生了什麼事情是index.php在/處被訪問,任何東西都在它之後被訪問,比如!index.php被作爲GET變量處理。我添加了一些可以重定向到404,如果在uri – steve76

0

另一種方法來做到這一點,一個比由CHOWN建議的其它,是內""寫入的文件名。

例子:

rm "!abc.html" "~qwerty.php" 
+0

裏有!,〜或%20,那麼'rm「!abc.html」'可能不起作用,這取決於'histexpand'的shell設置, !'作爲特殊字符(參見「man bash」中的'HISTORY EXPANSION'一節)。這就是爲什麼你必須使用'rm \!abc.html'來確保刪除文件。 –

0

如果你不喜歡的角色!的特殊處理,使用set +H在你的shell把歷史的擴張。有關詳細信息,請參閱man bash中的'HISTORY EXPANSION'部分。

有趣的是,我可以刪除從~開始的文件,而不必轉義文件名。