Where to start First steps track · 15 stages
Linux Labs

Output redirection and pipelines

cheat sheet · Ubuntu 24.04 · Bash 5.2 https://lab.dimsanych.ru/en/wiki/redirection/

Cheat sheet

  • cmd > out.txt output to a file (overwrite)
  • cmd >> out.txt output appended to a file
  • cmd 2> err.txt errors to a file
  • cmd > all.txt 2>&1 output and errors in one file
  • cmd &> all.txt the same, shorter (bash)
  • cmd 2>/dev/null throw errors away
  • cmd < in.txt input from a file
  • cmd1 | cmd2 cmd1's output into cmd2's input
  • cmd 2>&1 | less into a pipe together with errors
  • cmd | tee out.txt both to the screen and to a file
Loading…