Batch File Redirection

来源:互联网 发布:it 网络管理系统 价格 编辑:程序博客网 时间:2024/05/16 07:14

Redirection

Commands Description 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)


Notes:
  (1) Where the table mentions redirection to a file you may also use redirection to a device. Redirection from a device is not always possible.
  (2) Redirection to the NUL device is often used to hide standard output, instead of displaying it on screen:
    COPY *.* A: > NUL
  Another frequently used redirection is redirection to a parallel port to print standard output:
    DIR > LPT1

For details, please go to http://www.robvanderwoude.com/redirection.php

0 0
原创粉丝点击