What does `>` operator do?

QuestionsQuestions8 SkillsProPermissions of FilesSep, 03 2025
0146

The > operator in a Unix-like environment is used for output redirection. Here's what it does:

  • Redirects Output: It takes the output of a command and writes it to a specified file.
  • Overwrites Files: If the specified file already exists, using > will overwrite its contents with the new output. If the file does not exist, it will create a new file.

Example:

echo "Hello, world" > example.txt

In this example, the text "Hello, world" is written to example.txt. If example.txt already had content, that content would be replaced.

If you want to append to a file instead of overwriting it, you would use >> instead.

If you have any more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!