美文网首页
对man bash的总结(二)

对man bash的总结(二)

作者: 小胖_20c7 | 来源:发表于2019-06-27 12:14 被阅读0次
SHELL GRAMMAR
Simple Commands
定义:
      optional variable assignments + cmd + redirections + terminated by a control operator
返回值:
      1 return value(正常退出)
      2 128+n(信号终止)
特别注意:
      重定向的优先级是属于Simple Commands级别的
Pipelines
定义:
      command1 |& command2 | command3
特别注意:
      先进行管道连接,再进行重定位
      管道的特点就是A,B两个进程的创建是有关系的,但之后两个进程独立执行
Lists
分隔符:
      ;  &  &&  ||
分隔符优先级:
      (&& = ||) > (; = &)
结束符:
      ;  &  <newline>
定义:
      command1 分隔符 command2 结束符
特别注意:
      a && b | c & d = (a && (b | c) &) d
Compound Commands
Grouping Commands:
      (list),创建一个subshell环境,在这个环境下执行list
      { list; },在当前shell环境下,执行list
Looping Constructs:
      until test-commands; do consequent-commands; done
      while test-commands; do consequent-commands; done
      for name [ [in [words …] ] ; ] do commands; done
      for (( expr1 ; expr2 ; expr3 )) ; do commands ; done
Conditional Constructs:
      if语句
      case语句
      (( expression ))
      [[ expression ]]
            1 ==或者!=进行的是 '模式匹配'(不是正则)
            2 =~进行的是 'ERE查找',注意BASH_REMATCH
            3 对待转义的处理:
                  如果相关字符被引用,则传递普通字符给bash的正则处理
                  如果相关字符没被引用,则传递模式字符给bash的正则处理
                  引用 = '' or \
                  举例:
                        'test.txt',则传递普通字符'.'给正则,即'\.'
                        test.txt,则传递模式字符'.'给正则,即'.'

相关文章

网友评论

      本文标题:对man bash的总结(二)

      本文链接:https://www.haomeiwen.com/subject/edplcctx.html