010-150 · Question #84
You enter the command date +%M. Wat does the output show you?
The correct answer is D. the current minute. The date command uses format sequences where %M specifically represents the current minute of the hour, padded with a leading zero if necessary.
Question
You enter the command date +%M. Wat does the output show you?
Options
- Athe current year
- Bthe current month
- Cthe current hour
- Dthe current minute
- Ethe current second
How the community answered
(21 responses)- A5% (1)
- B5% (1)
- C10% (2)
- D81% (17)
Why each option
The date command uses format sequences where %M specifically represents the current minute of the hour, padded with a leading zero if necessary.
The current year is produced by %Y (four-digit) or %y (two-digit), not %M.
The current month is produced by %m (numeric) or %B/%b (name), not %M - note the case difference is significant.
The current hour is produced by %H (24-hour) or %I (12-hour), not %M.
In the date command's format string syntax, %M is the format specifier for minutes, displaying a zero-padded two-digit value from 00 to 59. The + sign introduces the format string, so date +%M outputs only the current minute component of the time.
The current second is produced by %S, not %M.
Concept tested: date command format specifiers for time components
Source: https://www.man7.org/linux/man-pages/man1/date.1.html
Topics
Community Discussion
No community discussion yet for this question.