panel 1: the magic of pipes is that you can use any program with any other program ANYTHING that outputs text => ANYTHING that takes text input panel 2: pipe some output env | grep MAIL panel 3: redirect stdout to a file pbpaste > ~/bin/git-vee panel 4: ignore error output find . 2>/dev/null panel 5: pipe both stderr and stdout to a program cmd 2>&1 | less panel 6: redirect both stderr and stdout to the same file cmd &> file.txt cmd > file.txt 2>&1 panel 7: gotcha: sudo echo blah > file.txt doesn't work if `file.txt` is owned by root, you have to do echo blah | sudo tee file.txt panel 8: gotcha: grep blah file.txt > file.txt will make file.txt empty you can use sponge but I always just make sure to write to a different file panel 9: gotcha: ./some_program | grep blah often gets buffered this is because libc buffers writes to files and pipes workaround: unbuffer some_program | grep blah (unbuffer is part of expect)
https://cdn.masto.host/socialjvnsca/media_attachments/files/113/408/478/607/373/110/original/1206e8debbaa33c8.png