~/ learn/ comp-325/ cards/ Making the shell leave your text alone
1 of 9

Four spellings of one variable — type all four and watch the results diverge

Four spellings of one variable — type all four and watch the results diverge

Answer

echo $HOME echo "$HOME" echo '$HOME' echo \$HOME

Lines 1 and 2 print the value; lines 3 and 4 print the five literal characters. The difference between 1 and 2 only shows up when the value contains a space — then line 1 passes several arguments and line 2 passes one.

Sarwar & Koretsky 3e ch2 §2.9; ch7 §7.5

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/ee4c85a1-06c2-44dd-87ea-a33d70722625/flashcard utf-8 LF