Redirection#
리다이렉션은 왼쪽에서 오른쪽 순서로 처리되므로 순서가 중요하다.
> /dev/null 2>&1 vs 2>&1 > /dev/null#
1. > /dev/null 2>&1#
stdout과 stderr이 모두 무시된다.
> /dev/null: stdout을/dev/null로 보낸다2>&1: stderr을 stdout의 현재 위치(즉,/dev/null)로 보낸다
2. 2>&1 > /dev/null#
stdout만 무시되고, stderr은 여전히 터미널에 출력된다.
2>&1: stderr을 stdout의 현재 위치(터미널)로 보낸다> /dev/null: stdout을/dev/null로 보낸다
&>#
stdout과 stderr을 동일한 목적지로 리다이렉트하는 Bash 단축어. &> <file>은 > <file> 2>&1와 동일하다.
eg. $ ls <file> &> /dev/null