What does the command `echo "Hello" > greeting.txt` do?

Prepare for the LPI 101-500 Certification Exam. Utilize flashcards, navigate multiple choice questions, and benefit from hints and explanations. Begin your Linux certification journey today!

The command echo "Hello" > greeting.txt creates a file named greeting.txt if it does not already exist and writes the string "Hello" to it. The redirection operator > is used here, which directs the output of the echo command into the specified file. If greeting.txt already exists, this command will overwrite its contents with "Hello".

This behavior of redirection is fundamental in Linux, as it allows for straightforward file creation and content management through command-line operations. The command effectively ensures that greeting.txt will have the exact content "Hello," regardless of its previous state.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy