linux命令中的‘--’解释

来源:互联网 发布:微博淘宝优惠券安全吗 编辑:程序博客网 时间:2024/05/16 00:41
Linux中"-"有特殊的含义,比如在命令的后面加"-"表示后面跟的是选项。但是如何新建带名字中有"-",可以用vi -- -a

  在当前目录下新建一个"-a"文件,当然还可以有别的方法新建,这里就不在介绍。如果要删除"-a"就比较麻烦了,如果你输入 rm -a,系统会提示你:
  rm:无效选项 -- a
  请尝试执行‘rm --help’来获取更多信息。
  对于这样的文件可以有两种方法来删除,如下所示:
  1、rm ./-a
  2、rm -- -a
  改名字也不用说了,基本上就是在文件名前面加"--"来表示转义字符就可以了!
 


NOTE

     The rm command uses getopt(3) to parse its arguments, which allows it to accept the `--' option which will

     cause it to stop processing flag options at that point.  This will allow the removal of file names that begin

     with a dash (`-').  For example:

           rm -- -filename

     The same behavior can be obtained by using an absolute or relative path reference.  For example:

           rm /home/user/-filename

           rm ./-filename


0 0
原创粉丝点击