The pipe | sends output to the next command: ps aux | grep nginx. Use > to write to a file, >> to append, and 2>/dev/null to discard error messages. Redirect both stdout and stderr with &> file.
Pipes and Redirection
# Pipe output to next command
ls -la | grep ".txt"
ps aux | grep nginx
cat file.txt | wc -l
# Redirect to file
echo "hello" > file.txt # overwrite
echo "world" >> file.txt # append
ls > files.txt 2>&1 # include errors
# /dev/null — discard output
command > /dev/null 2>&1