博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
bash中的特殊文件夹
阅读量:6228 次
发布时间:2019-06-21

本文共 2144 字,大约阅读时间需要 7 分钟。

  hot3.png

今天整理磁盘的时候发现一个文件夹叫做‘-help'

$ ls -F-help/

尝试进去看看里边有什么东西,却发现怎么也进不去

$ cd -helpbash: cd: -h: invalid optioncd: usage: cd [-L|-P] [dir]$ cd '-help'bash: cd: -h: invalid optioncd: usage: cd [-L|-P] [dir]$ cd "\-help"bash: cd: \-help: No such file or directory

对于其他的特殊字符,通常单引号就可以搞定了

$ ls -F help/  #help/  -help/ \help/$ cd #help$ pwd~$ cd -cd /tmp$ cd '#help'$ pwd/tmp/#help$ cd ..$ cd ' help'$ pwd/tmp/ help$ cd ..$ cd '\help'$ pwd/tmp/\help

那'-help'到底要怎么进呢。 在这里不得不再次吐槽一下百度,怎样都查不到想要的结果,“cd 减号开头 目录” “cd -开头目录” “cd 特殊字符目录” 全部查不到! 查!不!到!

只好google,一查必中,都不用全部输入,输入'cd -' 相关推荐就是我想要的东西了。 

下边是正确答案了,如果你看我啰嗦到这里,我相信,是真爱,哈哈哈。

答案来自  ,两种方法,其中“--” 这个选项,又是我所不知道的,要学的东西太多,加油!

  1. Use the -- argument.

    cd -- -2

    This uses a convention common to GNU tools which is to not treat anything that appears after -- as a command line option.

    As a noted, this convention is also :

    Default Behavior: When this section is listed as "None.", it means that the implementation need not support any options. Standard utilities that do not accept options, but that do accept operands, shall recognize "--" as a first argument to be discarded.

    The requirement for recognizing "--" is because conforming applications need a way to shield their operands from any arbitrary options that the implementation may provide as an extension. For example, if the standard utility foo is listed as taking no options, and the application needed to give it a pathname with a leading hyphen, it could safely do it as:

    foo -- -myfile
       

    and avoid any problems with -m used as an extension.

    :

    Guideline 10:

     The argument -- should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character. The -- argument should not be used as an option or as an operand.

  2. Specify the path explicitly:

    cd ./-2

    This specifies the path explicitly naming the current directory (.) as the starting point.

    cd $(pwd)/-2cd /absolute/path/to/-2

    These are variations on the above. Any number of such variations may be possible; I'll leave it as an exercise to the reader to discover all of them.

转载于:https://my.oschina.net/maxio/blog/637622

你可能感兴趣的文章
Android之——自己主动挂断电话的实现
查看>>
springcloud-01-介绍
查看>>
sqlite自己主动更新数据库
查看>>
管理中的外行与内行
查看>>
【5】JVM-垃圾收集器
查看>>
音频变调技术
查看>>
Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
查看>>
解决App can’t be opened because it is from an unidentified developer
查看>>
读《那些年,那些事 一个程序猿的奋斗史》 一点自己的感触
查看>>
Java,泛型类型通配符和C#对照
查看>>
LeetCode(1) Symmetric Tree
查看>>
Curl命令
查看>>
HDU 2181 DFS
查看>>
Linux 用C语言判断文件和文件夹
查看>>
Eclipse中jsp、js文件编辑时,卡死现象解决汇总
查看>>
图的基本知识
查看>>
leetcode第一刷_Same Tree
查看>>
高速排序之算法导论实现
查看>>
$.post()提交了数据,return不给跳转
查看>>
检测和删除多余无用的css
查看>>