Which redirection operator is used to append lines to a file when building it incrementally?

Study for the SANS560 GIAC Penetration Tester (GPEN) Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

Which redirection operator is used to append lines to a file when building it incrementally?

Explanation:
When you want to add content to a file without losing what’s already there, you use an append redirection. The operator that appends is the double angle bracket: >>. It opens the file in append mode, adding new lines to the end and creating the file if it doesn’t exist. This is ideal for building a file step by step, preserving everything written previously. In contrast, a single angle bracket > would overwrite the file, erasing everything that was there before, which defeats incremental building. The other symbols serve different purposes: a pipe | forwards output to another command, and a && simply chains commands so the next runs only if the previous succeeded.

When you want to add content to a file without losing what’s already there, you use an append redirection. The operator that appends is the double angle bracket: >>. It opens the file in append mode, adding new lines to the end and creating the file if it doesn’t exist. This is ideal for building a file step by step, preserving everything written previously. In contrast, a single angle bracket > would overwrite the file, erasing everything that was there before, which defeats incremental building. The other symbols serve different purposes: a pipe | forwards output to another command, and a && simply chains commands so the next runs only if the previous succeeded.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy