Exam LFCS All QuestionsBrowse all questions from this exam
Question 116

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

    Correct Answer: A

    To put the output of the command date into the shell variable mydate, you should use command substitution. The correct syntax for command substitution in a shell script is to enclose the command in $(..). Therefore, mydate=$(date) will execute the date command and assign its output to the mydate variable.

Discussion
9866666Option: A

root@CT101:~# echo $mydate Tue Jun 25 11:05:20 UTC 2024 root@CT101:~#

9866666

root@CT101:~# mydate="$(date)" root@CT101:~# echo $mydate Tue Jun 25 11:05:20 UTC 2024 root@CT101:~#