QuestionQ24

VerifiedTroubleshooting

In the echo "profile-$num-$name" line of a shell script, the $num variable appears not to expand when the script runs. Which notation ensures that its value expands?

Explanation

In a double-quoted shell string, ${num} performs parameter expansion while clearly delimiting the variable name. Single quotes suppress expansion, and $(num) attempts command substitution rather than expanding the num variable.

Community Discussion

No comments yet. Be the first to start the discussion!