bash variable operation

Variable interception

Intercept $varthe first 5character of the variable to 0:5indicate the subscript

echo ${var:0:5}

Variable substitution

The variable $varin 从左开始第一个acharacter replacedx

echo ${var/a/x}

Replace all characters $varin the variable awithx

echo ${var//a/x}

Guess you like

Origin blog.csdn.net/Free_time_/article/details/107742245