What is I/O redirection?

In the shell, switching where a command's standard input, standard output and standard error go, to a file or elsewhere instead of the screen or keyboard. > overwrites a file, >> appends to its end, < makes a file the standard input, and 2> sends standard error (number 2) to a file. 2>&1 points standard error to where standard output goes "at that moment", so > file 2>&1 and 2>&1 > file give different results.

Japanese name: 入出力のリダイレクト

I/O redirection appears in 2 practice questions across 1 topic, including Linux and Command-Line Basics.

Field: Linux and Command-Line Basics

I/O redirection in the explanations

Questions that mention I/O redirection (2)

  1. When the commands above are run in order, which of the following is the content shown by the last cat?
  2. As shown above, in a directory where a.txt exists and nofile does not, the last command is run. Which of the following is the result?

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

Related terms

cron Environment variable File permissions Git grep Hard link inode Pipe (|) Regular expression Shell

Back to the glossary