everyone, i have a problem in bash programming, that is I don’t know what’s mean in bash
script:
${parameter:-word}
${parameter:=word}
${parameter:?word}
${parameter:+word}
${parameter:offset}
${parameter:offset:length}
${!prefix*}
${#parameter}
${parameter#word}
${parameter##word}
${parameter%word}
${parameter%%word}
${parameter/pattern/string}
${parameter//pattern/string}
this usage, thank you for answer me .
If you just open up a terminal window and enter
man bash, you’ll be able to find all of these underParameter Expansion.In fact, since these are exactly the form in which the man page has them (using
parameterandword) and in the same order you have them, I’m surprised you don’t know this already.One example is
${parameter:-word}which states:So, for that case,
${xyzzy:-plugh}will give you the value of${xyzzy}if it’s set, otherwise you’ll get the literal"plugh".I won’t go through them all, the
bashman page explains in full detail. “Teach a man to fish …” and all that stuff.