Every Linux program interacts with three core data streams:
stdout)ls -l /usr/bin > ls-output.txtThis redirects output to a file instead of displaying it in the terminal.
stderr)ls -l /bin/usr 2> ls-error.txtError messages are saved to a separate file, while standard output remains visible.
stdout and stderrls -l /bin/usr > ls-output.txt 2>&1ls -l /bin/usr &> ls-output.txtls -l /usr/bin >> ls-output.txtAppends new data to the existing file content.
/dev/nullls -l /bin/usr 2> /dev/nullRedirects error messages to the "bit bucket" where they are ignored.
cat with stdincat filenamecat > lazy_dog.txtEnds input with Ctrl+D.
cat < lazy_dog.txt|ls -l /usr/bin | lessPasses output of one command as input to another.
ls /bin /usr/bin | sort | uniq | lessls /bin /usr/bin | sort | uniq -d | lesswcls /bin /usr/bin | sort | uniq | wc -lgrepls /bin /usr/bin | sort | uniq | grep zipOptions: -i (ignore case), -v (invert match)
head and tailhead -n 5 ls-output.txt
tail -n 5 ls-output.txttail -f:tail -f /var/log/messagesteels /usr/bin | tee ls.txt | grep zipSaves full list to file while allowing filtered output downstream.
By mastering Linux I/O streams and pipeline mechanics, users can redirect output, control errors, filter results, and structure complex data-processing workflows. Tools like sort, wc, grep, tee, and /dev/null empower users to manage data like pros within the shell environment.