nerdexam
LPI

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.

The Power of the Command Line

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)
  • A
    5% (1)
  • B
    5% (1)
  • C
    10% (2)
  • D
    81% (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.

Athe current year

The current year is produced by %Y (four-digit) or %y (two-digit), not %M.

Bthe current month

The current month is produced by %m (numeric) or %B/%b (name), not %M - note the case difference is significant.

Cthe current hour

The current hour is produced by %H (24-hour) or %I (12-hour), not %M.

Dthe current minuteCorrect

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.

Ethe current second

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

#date command#format specifiers#time display#command output

Community Discussion

No community discussion yet for this question.

Full 010-150 Practice