LFCS Exam QuestionsBrowse all questions from this exam

LFCS Exam - Question 116


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

Show Answer
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

1 comment
Sign in to comment
9866666Option: A
Jun 25, 2024

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

9866666
Jun 25, 2024

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