Updated: 28 September 2026 · Applies to: AlmaLinux 9, Rocky Linux 9, Ubuntu 24.04 and Debian 12

Send a command's output to a file or to another command:

ls *.png > images.txt          # write output to a file (overwrite)
ls *.jpg >> images.txt         # append to a file
command 2> errors.txt          # write errors to a file
command > all.txt 2>&1         # output and errors to one file
command > /dev/null 2>&1       # discard everything
ls | grep backup               # pipe output into another command
command | tee out.txt          # show output and save it

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)