LPIC-1 Exam 102 (Linux Administrator) — Question 17
Which of the following commands puts the output of the command date into the shell variable mydate?
Answer options
- A. mydate="$(date)"
- B. mydate="exec date"
- C. mydate="$((date))"
- D. mydate="date"
- E. mydate="${date}"
Correct answer: A
Explanation
The correct answer A uses command substitution with $(...) to capture the output of the date command and assign it to mydate. Options B and D do not execute the command correctly for variable assignment, while C uses arithmetic expansion incorrectly, and E tries to reference an already existing variable instead of executing the command.