Linux

Python Console 값 파일 text로 저장하기

MJSon 2017. 6. 5. 00:12
c좋다. 파이썬 스크립드를 sout.py라고 저장하고, 출력을 파일로 redirect 시도해보자.
$ ./sout.py > test.txt
I am stderr

standard output은 redirect가 되었지만, stderr은 그대로 화면으로 보여진다.
stderr을 refirect하고, stdour만 화면에 보여지게 하려면?
./sout.py 2> test.txt
stdout 과 stderr 둘다 파일로 저장하고 싶다면
./sout.py 2&> test.txt
마지막으로, stdout 과 stderr 둘 다 화면과 파일로 동시에 redirect하고 싶다면
./sout.py 2>&1 | tee test.txt