当我这样做时:
$ /bin/echo 123 | /bin/echo
页: 1 为什么如此?
当我这样做时:
$ /bin/echo 123 | /bin/echo
页: 1 为什么如此?
您询问为什么不工作。 事实上,它确实是行之有效的;它确实是你告诉它做的事。 显然,这不符合你的期望。 我认为,你希望能打印<条码>123<>>>,但你实际上没有这样做。
(说明:“基本”是标准投入;“基本”是标准产出。)
bin/echo 123 >
这里发生的情况。 <代码>echo的指挥用123
执行。 它撰写了“123”,之后是一条新路线,然后排出。
排泄物通过管道( /code>)转至第二个<代码>echo
的排位。 由于反应指挥忽视了它的困境,第一次反应的结果被qui弃。 既然你没有给出第二点回合,就没有印刷任何东西。 (实际上,没有任何论点通常印上单一空白线;你是否看到?)
通常的管道( > /code>)用在filters上,节目从零页读到尾。 <代码>cat
或许是最简单的过滤器;它只是读到其投入,并未作改动书写其产出(这意味着<代码>-command > cat<>>>>>t-command >.
非中上层过滤器的一个实例是rev
,其复制件在扭转每一行的特性时都停下来。
echo 123 | rev
印刷
321
<代码>rev是一个过滤器;echo
不是。 <代码>echo确实印刷成剪辑,因此将其放在管道左侧是明智的,但从管道中读出的是斜体,因此,在管道右侧使用它并无意义。
"echo" reads from command line, not standard input. So pipeline is not working here.
手册:
echo [-neE] [arg ...]
Output the args, separated by spaces, terminated with a newline.
因此,你第一次回合用了“123”印成不变的产出,但第二次回合用的是“123”。 然后,一个空线的印本是你“cho”。
You can use cat as Keith Thompson suggested:
echo 123|cat
/bin/echo 123 < /bin/echo
管道 = 类别
rel=“nofollow” http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-4.html
Pipes let you use the output of a program as the input of another one
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 ...