Bash Variable Expansions

By Taha5 minutes read


${#variable}


${variable%pattern}


${variable#pattern}


${variable%%pattern}


${variable##pattern}


${variable^}


${variable^^}


${variable^^pattern}


${variable,}


${variable,,}


${variable,,pattern}


${variable~}


${variable~~}


${variable~~pattern}


${variable/pattern/replacement}


${variable//pattern/replacement}


${variable/%pattern/replacement}


${variable/#pattern/replacement}


${variable:position}


${variable:position:length}


${variable: -position}


${variable: -position:length}


${variable:+value}


${variable:-value}


${variable:?message}


${variable:=value}


${!prefix*} and ${!prefix@}


${variable[*]} and ${variable[@]}


${parameter@operator}


Conclusion

References