Linux Pipes and Redirects: Combine Commands Like a Pro
Tools You'll Need
Terminalgrepless
The | (pipe) sends one command's output into another:
ls -l | less: scroll through a long list (Q to quit)
history | grep apt: find install commands you typed before
dmesg | grep -i usb: only USB messages
ls | wc -l: count files in a folder
ps aux | grep firefox: find a running program
Save output to a file:
ls > list.txt: write (replaces the file)
date >> log.txt: add to the end
command 2> errors.txt: save only error messages
Combine: sort names.txt | uniq > clean.txt removes duplicate lines.