What if you could save any command's output instantly without lifting a finger?
Why stdout redirection (>, >>) in Linux CLI? - Purpose & Use Cases
Imagine you run a command in the terminal that shows a long list of information, like all files in a folder. You want to save this list to a file to look at later. Without redirection, you have to copy the text manually from the screen and paste it into a file.
Copying text manually is slow and easy to mess up. You might miss some lines or accidentally copy extra spaces. If the output is very long, scrolling back to find it is frustrating. Also, doing this repeatedly wastes time and can cause errors.
Using stdout redirection with > or >> sends the output of a command directly into a file. This means you don't have to copy anything by hand. The first symbol > creates or replaces a file, while >> adds to the file without deleting what's already there.
ls -l
# Then copy output manually to a filels -l > filelist.txt ls -l >> filelist.txt
You can quickly save command results to files for later use, making your work faster and more reliable.
When checking server logs, you can redirect error messages to a file to review them later instead of watching them scroll by on the screen.
Manual copying of command output is slow and error-prone.
Stdout redirection sends output directly to files automatically.
> overwrites files, >> appends to files.