How does '>' differ from '>>'?

0127

The > and >> symbols are both used for output redirection in the command line, but they serve different purposes:

  1. > (Output Redirection):

    • The > symbol is used to redirect the output of a command to a file, overwriting the file if it already exists.
    • Example:
      echo "Hello, World!" > output.txt
      This command will create (or overwrite) output.txt with the text "Hello, World!".
  2. >> (Append Redirection):

    • The >> symbol is used to append the output of a command to a file, preserving the existing content of the file.
    • Example:
      echo "Hello again!" >> output.txt
      This command will add "Hello again!" to the end of output.txt without deleting the existing content.

In summary, > overwrites the file, while >> appends to it.

0 Comments

no data
Be the first to share your comment!