The > redirection operator in shell scripting truncates the target file (or creates it if it doesn't exist) and writes the new output to it, replacing any existing content. In contrast, >> appends output to the end of the file without removing existing content, < is used for redirecting input into a command (not output to a file), and piping (|) sends output to another command's input, not to a file — attempting to pipe into a filename like foobar.txt would result in an error since it's not a recognized command.
Community Discussion