Basic redirections:

  • command > fileĀ  = send output of command to file and overwrite previous content of the file
  • command >> file = append output of command to file
  • command < file = content of the file is send as input into command

Multiple redirections:

  • command 2>file = redirects standard error to file, standard output is not changed ( be avare “2>file” must be written without spaces)
  • command 2>&1 = redirects standard error to standard output
  • command > file1 2>file2 = redirects standard output to file1 and standard error to file2
  • command > file 2>&1 = redirects standard output to file and standard error to standard output – i.e. also to file (this can be written also as “command >& file” or “command &>file” )