linux进入字符目录,linux – 如何使用此名称“-2”(以连字符开头)进入cd目录?

至少有两种方式:

>使用 – 参数.

cd -- -2

这使用GNU工具常用的约定,它不会处理之后出现的任何内容 – 作为命令行选项.

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:

06001

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.

>明确指定路径:

cd ./-2

这指定了显式命名当前目录(.)作为起点的路径.

cd $(pwd)/-2

cd /absolute/path/to/-2

这些是上面的变化.任何数量的此类变化都是可能的;我将把它作为练习留给读者发现所有这些.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值