티스토리 뷰

dir >log.txt 2>&1


1 : StdOut

2 : StdErr

3 : Console


- 2>&1 : StdErr(도 ) StdOut 으로 Redirect


- >log.txt 2>&1

dir 결과(StdOut)를 log.txt 에 출력함. StdErr 도 StdOut 에 같이 보냄..



- 출처 : 

http://www.robvanderwoude.com/battech_redirection.php


https://superuser.com/questions/698496/log-an-entire-batch-file-output?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa



* 파일출력 & 화면 출력 동시에 가능한가? 


dir >log.txt 2>&1 1>&3

오류남


dir >log.txt 2>&1 | type log.txt


dir 과 동시에 type 이 실행되므로 운좋으면 화면에 보일 수도 있지만,

계속 진행되는 명령은 type이 먼저 끝나버리고 아무것도 보이지 않음.


https://social.technet.microsoft.com/Forums/Lync/en-US/6144cf29-d703-45f8-a28b-ff8c5ded567b/output-batfile-to-console-and-logfiletxt?forum=ITCG


위 링크에 의하면 tee 명령 말고는 불가능 하다고 함.

(여러 방법 제시해놓았으나 된건 없어).






* 기타 복잡한 문법 응용

https://stackoverflow.com/questions/503846/how-do-i-echo-and-send-console-output-to-a-file-in-a-bat-script?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa




https://stackoverflow.com/questions/20484151/redirecting-output-from-within-batch-file?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함