zoukankan      html  css  js  c++  java
  • bash中花括号{1..10}的注意事项

    bash shell中,我们执行echo {1..10},会打印1-10这些数字

    [root@localhost ~]# echo {1..10}
    1 2 3 4 5 6 7 8 9 10
    

    但是有个前提,这其中的{1..10}不能带上引号,单双引号,反引号都不行。这是花括号的实现限制,如果想仔细了解,man bash,搜索Brace Expansion看这样一段话

    Brace Expansion
           Brace expansion is a mechanism by which arbitrary strings may be generated.  This mechanism is similar to pathname expansion, but
           the filenames generated need not exist.  Patterns to be brace expanded take the form of an optional preamble, followed by  either
           a  series  of comma-separated strings or a sequence expression between a pair of braces, followed by an optional postscript.  The
           preamble is prefixed to each string contained within the braces, and the postscript is then appended to  each  resulting  string,
           expanding left to right.
    
           Brace expansions may be nested.  The results of each expanded string are not sorted; left to right order is preserved.  For exam‐
           ple, a{d,c,b}e expands into `ade ace abe'.
    
           A sequence expression takes the form {x..y[..incr]}, where x and y are  either  integers  or  single  characters,  and  incr,  an
           optional increment, is an integer.  When integers are supplied, the expression expands to each number between x and y, inclusive.
           Supplied integers may be prefixed with 0 to force each term to have the same width.  When either x or y begins with a  zero,  the
           shell  attempts to force all generated terms to contain the same number of digits, zero-padding where necessary.  When characters
           are supplied, the expression expands to each character lexicographically between x and y, inclusive.  Note that both x and y must
           be of the same type.  When the increment is supplied, it is used as the difference between each term.  The default increment is 1
           or -1 as appropriate.
    

    我只是复制了一小段,详情可以自己翻看,总之记住这个就可以了。

  • 相关阅读:
    MATLAB中mexFunction函数的接口规范
    opencv 人脸识别 (一)训练样本的处理
    VS 编程常见错误及解决方法
    在用VC编译下debug和release的什么区别
    OpenCV中Mat的详解
    主成份分析PCA
    人脸识别必读的N篇文章
    opencv有关错误及解决办法
    解决办法:CMake编译时出现“error in configuration process project files may be invalid”
    mybatis 学习笔记(二):mybatis SQL注入问题
  • 原文地址:https://www.cnblogs.com/FengGeBlog/p/13027944.html
Copyright © 2011-2022 走看看