GIAC
GSNA · Question #194
What will be the output of the following command? echo $(date %M) > date.txt
The correct answer is D. The current time (Minutes) will be written in the date.txt file. The date command with the %M specifier prints the current time (Minutes). Since the output is redirected towards the date.txt file, the current time (Minutes) will be printed in the date.txt file.
Linux/Unix System Auditing
Question
What will be the output of the following command? echo $(date %M) > date.txt
Options
- AThe current time (Month) will be written in the date.txt file.
- BIt will create a variable $(date %M).
- CIt will print a string "date %M".
- DThe current time (Minutes) will be written in the date.txt file.
How the community answered
(25 responses)- A8% (2)
- B4% (1)
- C12% (3)
- D76% (19)
Explanation
The date command with the %M specifier prints the current time (Minutes). Since the output is redirected towards the date.txt file, the current time (Minutes) will be printed in the date.txt file.
Topics
#bash scripting#date command#command substitution#shell output redirection
Community Discussion
No community discussion yet for this question.