nerdexam
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)
  • A
    8% (2)
  • B
    4% (1)
  • C
    12% (3)
  • D
    76% (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.

Full GSNA Practice