nerdexam
LPI

117-101 · Question #203

In order to append the output of ls to a file called bazz, which of the following command lines would you use?

The correct answer is D. ls >> bazz. See the full explanation below for the reasoning.

Question

In order to append the output of ls to a file called bazz, which of the following command lines would you use?

Options

  • Als > bazz
  • Bls > & bazz
  • Cls &> bazz
  • Dls >> bazz

How the community answered

(37 responses)
  • A
    5% (2)
  • B
    16% (6)
  • C
    3% (1)
  • D
    76% (28)

Community Discussion

7
Carlos M.Carlos M.Feb 6, 2026

D is the one you want. The double right angle bracket appends stdout to the file instead of overwriting it, so anything already in bazz stays there and the new ls output gets added to the bottom. A with a single > would wipe bazz and start fresh each time, which is not append. B and C are for redirecting both stdout and stderr together, not for appending anything.

18
Luis F.Luis F.Jan 30, 2026

D is the one you want here because the double arrow >> is specifically the append operator in bash, meaning it adds to whatever is already in bazz instead of wiping it out and starting fresh. The single > in option A would truncate bazz to zero bytes first and then write, so you would lose anything that was already in there. Option C with &> is a bash shorthand that redirects both stdout and stderr to the file, but it still overwrites rather than appends. Does anyone know if the >> operator creates the file from scratch if bazz does not exist yet, or does it throw an error in that case, because I always assumed it creates it but I want to make sure I have that right before the exam.

5
Ola B.Ola B.Feb 7, 2026

D is right, and honestly this one trips people up because A looks totally reasonable until you remember that single > blows away whatever was already in bazz. Spin up a terminal, touch bazz, throw some text in it, then run ls > bazz and watch your content vanish, then do the same with >> and see it stack, that five-minute lab burns the difference into your brain better than any flashcard.

4
Orla P.Orla P.Feb 11, 2026

That space in B is intentional, it redirects both output streams to bazz.

-1
Ola B.Ola B.Feb 14, 2026

Orla, that space actually breaks the redirection, because the shell interprets "2>" as a separate redirect operator and then sees "&1" as a filename literal rather than a file descriptor reference. D has them written together as a single token, which is what correctly merges stderr into stdout before sending both to bazz.

0
Ingrid P.Ingrid P.Jan 24, 2026

A is the one I have drilled into my cards because the single redirect operator sends output to a file, and that is exactly what appending to bazz means. Every time I hit this card in my review queue it reinforces that ls > bazz is the clean, direct way to get it done.

-2
Luis F.Luis F.Jan 24, 2026

Ingrid, just a heads up, the answer is actually D because a single > would overwrite bazz each time, while >> is the append operator that adds to the file without wiping what is already there. So ls >> bazz is the one you want for appending.

0
Full 117-101 Practice