Parameter Expansion
noun
say it: “puh-RAM-uh-ter ek-SPAN-shun” /pəˈræmətər ɪkˈspænʃən/
A way of using a variable's value with a small change made on the way, such as cutting off its ending or filling in a default.
What is parameter expansion?
Parameter expansion is a variable written in ${ } with a change added, which the shell makes as it uses the value: ${f%.tmp} is f with .tmp cut off the end, and ${name:-friend} is friend when name is empty. The variable itself stays as it was.
f=telemetry/orbit-01.tmp
echo "${f%.tmp}.log" # telemetry/orbit-01.log
In a sentence
- “The greeting uses parameter expansion to fall back to Happy birthday when nothing was typed.”
- “With parameter expansion, ${f%.tmp} gives the name without its old ending.”
Level: Journeyman · More Unix terms at this level
Updated