非黑白的生活

用黑白的眼睛闪出七彩的生活!

« 2006年度病毒排行奖项Gmail技巧:谁泄露了你的邮箱地址 »

Linux/Unix下如何删除具有特殊字符的文件

假设Linux/Unix系统中有一个文件名叫“-target”,如果我们想对它进行操作,例如要删除它按照一般的删除方法在命令行中输入rm -target命令,界面会提示我们是“无效选项”(invalid option)

原来由于文件名的第一个字符为“-”,Linux/Unix把文件名当作选项了。我们可以使用“--”符号来解决这个问题,通过man rm可以知道

     A - permits the user to mark explicitly the end of any  com-
     mand  line  options, allowing rm to recognize file arguments
     that begin with a -. As an aid to  BSD  migration,  rm  will
     accept  -- as a synonym for -. This migration aid may disap-
     pear in a future release. If a -- and a - both appear on the
     same command line, the second will be interpreted as a file.

输入“rm -- -target”命令便可顺利删除名为“-target”的文件。

如果是其他特殊字符的话可以在特殊字符前加一个“”符号,或者用双引号把整个文件名括起来。

如果是远程主机,还可以通过在windows系统使用ftp工具连接,在windows下能正常对这些文件名进行操作。

本站所有原创作品均遵循 『 创作共用 Creative Commons 』协议
您可以随意转载我博客里的文章,但非我允许不得用于商业用途,转载的时候请在醒目的位置注明原文的出处并附上链接
本文链接地址:http://www.palfans.net/blog/post/2006/12/125.htm

如果这是您第一次访问本站,欢迎您点击,及时得到本站最近的更新。

发表评论:

[邮箱被保密,并能收到给您的留言回复。如已关联Gravatar,会同步您的头像]

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80722 Code detection by Codefense

Copyright 2005-2008© www.palfans.net. Some Rights Reserved.  渝ICP备05012425号