命令解释中option和non-option参数

案例:

[LeonHughes@localhost:Download]$find .  -maxdepth 1 -name 'g*'
./garnome-2.24.0
./gradetwo-fetion-e8224ae911604229f65f19230745723867baccc3.tar.gz


[LeonHughes@localhost:Download]$find .  -name 'g*' -maxdepth 1
find: warning: you have specified the -maxdepth option after a non-option argument -name, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

./garnome-2.24.0
./gradetwo-fetion-e8224ae911604229f65f19230745723867baccc3.tar.gz

原因:

GNU/Linux命令行习惯

   几乎所有的GNU/Linux程序都遵循一些同样的命令行解释习惯,程序的参数通常分为了两大类:选项(option)和non-option参数。选项(option)主要是提供给程序一些运行上的选择,起码限制约束作用;而non-option参数则通常是提供给程序运行的输入之类的值。

 

     find [-H] [-L] [-P] [path...] [expression],其中expression又分为options,tests和actions。-maxdepth属于expressions中的options,而-name属于exprestions中的tests。

     这就是上面第二个命令出现warning的原因。

 

option都是放在non-option之前的,如:

 nl [OPTION]... [FILE]...

 which [options] [--] programname [...]

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值