배치 스크립트 및 쉘 스크립트를 실행하다 보면, Redirect(> , >>)를 자주 사용하게 된다.

그런데 쉘 스크립트에서는 "2>&1" 를 활용하여, error 및 standard output을 파일 등에보내는 것은 잘 알려진 사실이었지만(내가 알고 있었지만), 윈도우즈 배치 스크립트에서도 똑같이 활용될 수 있다는 것을 오늘 처음 알았다.

 

역시 배움은 나의 힘!!! 

 

 

 

Redirection
command > file Write standard output of command to file
command 1> file Write standard output of command to file (same as previous)
command 2> file Write standard error of command to file (OS/2 and NT)
command > file 2>&1 Write both standard output and standard error of command to file (OS/2 and NT)
command >> file Append standard output of command to file
command 1>> file Append standard output of command to file (same as previous)
command 2>> file Append standard error of command to file (OS/2 and NT)
command >> file 2>&1 Append both standard output and standard error of command to file (OS/2 and NT)
commandA | commandB Redirect standard output of commandA to standard input of commandB
commandA 2>&1 | commandB Redirect standard output and standard error of commandA to standard input of commandB (OS/2 and NT)
command < file command gets standard input from file
command 2>&1 command's standard error is redirected to standard output (OS/2 and NT)
command 1>&2 command's standard output is redirected to standard error (OS/2 and NT)

 

이 글은 스프링노트에서 작성되었습니다.

Posted by 아프락사스
<< PREV : [1] : ... [22] : [23] : [24] : [25] : [26] : [27] : [28] : [29] : [30] : ... [160] : NEXT >>

BLOG main image

공지사항

카테고리

분류 전체보기 (160)
MAMP LAMP (1)
Open Project (4)
Knowhow (57)
JEE Technologies (3)
Rational Products (94)
Etc (0)