nerdexam
Novell

050-720 · Question #336

Which command displays the value stored in the $MYVAR variable?

The correct answer is D. echo $MYVAR. See the full explanation below for the reasoning.

Question

Which command displays the value stored in the $MYVAR variable?

Options

  • Aless MYVAR
  • Bcat $MYVAR
  • Cecho MYVAR
  • Decho $MYVAR

How the community answered

(23 responses)
  • A
    13% (3)
  • B
    4% (1)
  • C
    4% (1)
  • D
    78% (18)

Community Discussion

8
Anjali D.Anjali D.Mar 31, 2026

The correct answer is D, echo $MYVAR. In bash, the dollar sign is what tells the shell to treat MYVAR as a variable and substitute its stored value, so without it you are just printing the literal string "MYVAR" as plain text, which is what option C does. Options A and B are off track entirely, since less and cat are for reading file contents, and passing $MYVAR to cat means the shell tries to open a file named whatever the variable holds, not print the value. This is one of those questions where knowing the difference between a variable name and a variable reference really matters, so if anyone in the group is still fuzzy on when to use the dollar sign, drop a reply and we can work through a few more examples together.

8
Ingrid P.Ingrid P.Apr 1, 2026

One small addition worth a card of its own: echo without the dollar sign prints the literal string MYVAR, but echo with quotes around the variable, like echo "$MYVAR", is the habit to drill because unquoted variable expansion will split on whitespace and trip you up the moment the value contains spaces.

0
Samuel O.Samuel O.Apr 16, 2026

echo $MYVAR is your answer, and that dollar sign is doing all the heavy lifting because without it you're just printing the literal string "MYVAR" to the screen rather than dereferencing what the shell stored there. Did you already know that both single and double quotes treat that dollar sign differently, and do you know which one would actually suppress the variable expansion if you wrapped your echo in them?

0
Anjali D.Anjali D.Apr 18, 2026

Samuel is right that the dollar sign is the key, and to answer your question directly, single quotes suppress expansion so echo '$MYVAR' prints the literal string, while double quotes allow it so echo "$MYVAR" gives you the value.

0
Ingrid P.Ingrid P.Mar 24, 2026

I have this one on a card I review every 8 days and I keep landing on A, less MYVAR, because less is a pager utility that opens and displays file or variable content directly from the shell context, which is exactly what you need when you want to see what is stored in MYVAR without any extra syntax noise. The dollar sign prefix is for passing variables as arguments to commands like cat or echo, but less reads the identifier itself, so just feeding it the bare name MYVAR is the correct form here.

-1
Anjali D.Anjali D.Mar 24, 2026

Ingrid, I appreciate the detailed reasoning, but the shell actually requires the dollar sign to expand a variable, so without it, less treats MYVAR as a literal filename and tries to open a file by that name rather than reading the variable's contents. Option D uses the proper syntax to dereference the variable and display its value.

0
Mei-Ling H.Mei-Ling H.Apr 5, 2026

I keep coming back to A because "less MYVAR" pages through the content cleanly.

-2
Samuel O.Samuel O.Apr 5, 2026

Mei-Ling, the issue is that "less MYVAR" treats MYVAR as a literal filename, so the shell never expands the variable at all, which means you get a "No such file or directory" error rather than paged output. D is correct because it actually references the variable's value with the dollar sign prefix before piping or displaying it.

0
Full 050-720 Practice