它清楚地知道如何将一个过程的标准作用推向另一个进程的标准投入:
proc1 | proc2
但是,如果我想把表1的标准错误推到表2,并将标准产出留给目前的地点,那么什么呢? 页: 1 指挥线如下:
proc1 2| proc2
But, alas, no. Is there any way to do this?
它清楚地知道如何将一个过程的标准作用推向另一个进程的标准投入:
proc1 | proc2
但是,如果我想把表1的标准错误推到表2,并将标准产出留给目前的地点,那么什么呢? 页: 1 指挥线如下:
proc1 2| proc2
But, alas, no. Is there any way to do this?
There is also process substitution. Which makes a process substitute for a file.
You can send stderr
to a file as follows:
process1 2> file
But you can substitute a process for the file as follows:
process1 2> >(process2)
这里的具体实例是将<代码>stderr发送至标识符的屏幕和附录。
sh myscript 2> >(tee -a errlog)
可在swapstdout
和stderr
上使用下列trick。 然后,你才使用常规管道功能。
( proc1 3>&1 1>&2- 2>&3- ) | proc2
提供<<条码>tdout和stderr
,两者在开始时都指明同一地点,这将给你需要的东西。
<代码>x>&y bit do is to change file editedx
因此,它现在将其数据发送到目前处理<代码>y
的地点。 就我们的具体情况而言:
3>&1
creates a new handle 3
which will output to the current handle 1
(original stdout), just to save it somewhere for the final bullet point below.1>&2
modifies handle 1
(stdout) to output to the current handle 2
(original stderr).2>&3-
modifies handle 2
(stderr) to output to the current handle 3
(original stdout) then closes handle 3
(via the -
at the end).• 有效控制你在分类算法中看到的蒸p:
temp = value1;
value1 = value2;
value2 = temp;
Bash 4的特征是:
如果使用“S&”;标准指挥错误1与通过管道提供2号指挥标准投入有关;2号与2号;&1 >。 标准错误的这种间接转移是在指挥所指明的任何后进行的。
zsh也具有这一特点。
纽约总部
与其他炮弹/发炮弹一样,只是明确地进入这一轨道。
FirstCommand 2>&1 Other Command
偷窃是巨大的,因为它解决了这一问题。 如果你甚至不需要原封不动,你可以这样做:
proc1 2>&1 1>/dev/null | proc2
秩序至关重要;你不想:
proc1 >/dev/null 2>&1 | proc1
这将使所有东西转至<条码>。
其中没有一个真正行之有效。 我想做的是:
(command < input > output) 2>&1 | less
这只是针对以下情形开展工作:<代码>command。 不需要关键的投入。 指称:
(gzip -d < file.gz > file) 2>&1 | less
put误会减少
((echo one out; echo -e two err >&2) |wc) 2> >(wc)
I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...
How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks
I like to write bash shell scripts on my iPhone, put them in an app folder with an icon, plist, etc., so they execute like apps by tapping their icon on SpringBoard. This is not interactive like ...
From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...
I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...
I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...
I m 试图撰写一个双面文字,处理一个文件清单,其名字在投入档案中每栏一栏储存,就像一个一样。
Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...