Skip to main content
Linux AdministrationMediumSingle Choice

Linux Administration Question

Statement

Which of the following commands puts the output of the command date into the shell variable mydate?

#command substitution#variable assignment#date command#shell expansion
A

mydate="$(date)"

Correct
B

mydate="exec date"

C

mydate="$((date))"

D

mydate="date"

E

mydate="${date}"

Resolution & Explanations

Command substitution using $(...) is the standard and recommended way to capture the output of a command into a variable.