见以下两部产出指挥部:
hal@DESKTOP-B3IP76D:~$ wc < myfile.txt
4 4 34
hal@DESKTOP-B3IP76D:~$ cat myfile.txt | wc
4 4 34
我的理解是,这两条都把<代码>wc过程的第六部分与myfile.txt
的内容流联系起来。 但是,为什么产出在一种情况下是附加的,而不是在另一种情况下? 如何说明两者之间的区别? 难道这不只是从中去读吗?
见以下两部产出指挥部:
hal@DESKTOP-B3IP76D:~$ wc < myfile.txt
4 4 34
hal@DESKTOP-B3IP76D:~$ cat myfile.txt | wc
4 4 34
我的理解是,这两条都把<代码>wc过程的第六部分与myfile.txt
的内容流联系起来。 但是,为什么产出在一种情况下是附加的,而不是在另一种情况下? 如何说明两者之间的区别? 难道这不只是从中去读吗?
简短回答:由于<代码>wc < myfile.txt,wc
方案可直接查阅档案,除阅读外还可做事。 具体来说,它能够掌握档案的大小(它把产出栏按此计算)。 有了<条形形形形形形形形色色的薄膜>,它就能够这样做,因此它使用大的栏目确保有足够的房间。
长期答案:wc
努力提供单列的产出:
$ wc a.txt b.txt
6 6 88 a.txt
60 236 1772 b.txt
66 242 1860 total
为估算其栏目的广度, 如果能够拿到任何投入文件数量(例如,这些文件不是简单的档案,而是管道或类似材料),它就会“占到最糟糕的状态”,并且至少要花7位数。 因此,投入中的任何时间是any s>,即是管道或类似东西,你将再接上整个整个7个单元的栏目。 一些实例:wc
runs :
(或fstat(
)栏>)所有投入文件(在实际阅读这些文件以获取详细数字之前),以及
# direct input via stdin
$ wc a.txt - <b.txt
6 6 88 a.txt
60 236 1772 -
66 242 1860 total
# indirect input via cat and a pipe on stdin
$ cat b.txt | wc a.txt -
6 6 88 a.txt
60 236 1772 -
66 242 1860 total
# direct via file descriptor #4
$ wc a.txt /dev/fd/4 4<b.txt
6 6 88 a.txt
60 236 1772 /dev/fd/4
66 242 1860 total
# indirect input via cat and a pipe on FD #63
$ wc a.txt <(cat b.txt)
6 6 88 a.txt
60 236 1772 /dev/fd/63
66 242 1860 total
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 ...