全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Redirection?

Definition 8.5 University Computer Science — Year 1 · 第 8 章 — The Shell

A redirection connects a standard stream of a command to a file: > f sends standard output to f, emptied first; >> f appends to it; < f reads standard input from it; 2> f sends standard error; and 2>&1 sends standard error wherever standard output goes at that point of the line. Redirections are performed by the shell before the program starts, from left to right.

Standard output (1) and standard error (2) of ls. With > all.txt alone, the error still reaches the terminal; 2>&1, written after it, sends the error where the output goes now, to the file. Written before > all.txt, it would copy the old destination, the terminal ().
Standard output (1) and standard error (2) of ls. With > all.txt alone, the error still reaches the terminal; 2>&1, written after it, sends the error where the output goes now, to the file. Written before > all.txt, it would copy the old destination, the terminal (Exercise 8.6).
在原文中阅读 →