Linux Redirection Operators: >, >> and |

Shell redirection operators control where command input and output go. They are useful for saving command output, appending logs, and passing one command’s output into another command.

Write output to a file

ls -l > files.txt

> writes output to a file. It replaces the existing file contents.

Append output to a file

date >> activity.log

>> appends output to the end of a file.

Pipe output to another command

ps aux | grep ssh

| sends the output of one command into another command for filtering or further processing.

Leave a Comment