QuestionQ153

Essential Commands

Which command below stores the output of the date command in the shell variable mydate?

  • A mydate="$(date)"
  • B mydate="exec date"
  • C mydate="$((date))"
  • D mydate="date"
  • E mydate="${date}"
Explanation

$(date) is command substitution in the shell: it runs date and substitutes its standard output into the assignment to mydate.

Community Discussion

No comments yet. Be the first to start the discussion!