~/ learn/ comp-325/ cards/ Globbing, Quoting, and the Shell Environment
1 of 48

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/e7d1a5cf-0fc5-41e6-80fa-789fea4b3fa8/flashcard utf-8 LF