In linux shell substr (split string), if a string is intercepted in shell, substr in awk is called. Today I learned a new method, which is supported by shell itself. For example, if there is a string "12345678", You need to extract the string range of the third to sixth characters. You can: [xok. la ~] $ Export str = "123456789" [xok. la ~] $ Echo $ {str: 3 :( 6-3)} 456 [xok. la ~] $ Unset str can be seen from the second expression above, that is, $ {str: 3 :( 6-3)} can be summarized as: $ {str: begin: len }, and supports expressions, such as 6-3. I have found some other usage on the Internet: shell string truncation problem: 1. Linux shell intercepts the first eight digits of the character variable by using the following methods: 1. expr substr "$ a" 1 82. echo $ a | awk '{print substr (,)}' 3. echo $ a | cut-c1-84.echo $5. expr $ :'\(. \\). * '6. echo $ a | dd bs = 1 count = 8 2>/dev/null 2. truncate by specified string 1. Method 1: $ {varible # * string} captures the string behind the last string from left to right $ {varible # * string} captures the string behind the first string from left to right $ {varible % string *} truncates the string $ {varible % string *} after the last string from the right to the left to extract the string "*" after the first string from the right to the left. Example: $ myvar1_foodforthought.jpg $ echo $ {MYVAR # * fow.rthought.jpg $ echo $ {MYVAR # * fow.odforthought.jpg 2. Method 2: $ {varible: n1: n2 }: truncates the string from n1 to n2 of the varble variable. You can use another form of variable extension to select a special character string based on the specific character offset and length. Try entering the following line in bash: $ EXCLAIM = cowabunga $ echo $ {EXCLAIM: 0: 3} cow $ echo $ {EXCLAIM: 3: 7} abunga string truncation is very simple. You only need to use a colon to separate the start character and the length of the substring. 3. Split according to specified requirements: for example, get the suffix ls-al | cut-d "."-f2