nerdexam
LPI

117-010 · Question #24

Which of the following commands redirects the output of cmd to the file foo.txt, in which an existing file is overwritten?

The correct answer is E. cmd > foo.txt. See the full explanation below for the reasoning.

Question

Which of the following commands redirects the output of cmd to the file foo.txt, in which an existing file is overwritten?

Options

  • Acmd || foo.txt
  • Bcmd | foo.txt
  • Ccmd && foo.txt
  • Dcmd >> foo.txt
  • Ecmd > foo.txt

How the community answered

(20 responses)
  • A
    5% (1)
  • B
    5% (1)
  • C
    10% (2)
  • E
    80% (16)

Community Discussion

6
Mei-Ling H.Mei-Ling H.Jun 27, 2026

E is correct. The single greater-than sign redirects standard output to a file and overwrites whatever is already there, while the double greater-than in D appends instead of overwriting, and the other options are not redirection operators at all.

15
Luis F.Luis F.Jun 27, 2026

E is right, > overwrites while >> appends, but do you know what happens if foo.txt doesn't exist yet?

5
Bao N.Bao N.Jun 29, 2026

If foo.txt does not exist, both > and >> will create it, so the only real difference is what happens when the file is already there.

0
Prof. SaraProf. SaraJun 16, 2026

Single right-arrow overwrites, double appends. Saw E on my LPI exam, chose it cold.

0
Orla P.Orla P.Jun 27, 2026

E is right. Does it click why >> writes differently than > does?

0
Bao N.Bao N.Jun 27, 2026

E nails it, but do you know why >> does something different?

0
Full 117-010 Practice