Shell scripting: pipe/redirect stdout and stderr








  • redirect stdout to file:
    ls > out.txt
  • redirect stderr to file:
    ls 2> err.txt
  • redirect stderr to stdout:
    my-command 2>&1 
  • redirect stdout to stderr:
    my-command 1>&2 
  • redirect stdout and stderr to file:
    my-command &> 1.txt



No comments:

Post a Comment