shell expansion 笔记

9月 5, 2017 |

Brace Expansion

mkdir ./{old,new,dist,bugs} #generate ./old, ./new, ./dist, ./bugs

Tilde Expansion

~ #The value of $HOME
~+/foo #$PWD/foo

Shell Parameter Expansion

${parameter} #parameter's value
${#parameter} #length of parameter
${!prefix@} #variable name begin with prefix
array[0]=01234567890abcdefgh
echo ${array[0]:7} #substring from index 7 to end
${parameter/pattern/string} #replace match pattern parts with string
${parameter^pattern} #change match pattern parts's case in parameter

Command Substitution

$(command) or ‘command‘

Arithmetic Expansion

$(( expression ))

Word Splitting

not within double quotes

Posted in: Linux

Comments are closed.