I wrote a 10000010-byte file (99010 rows of 100 consecutive
big for experimentation purposes. I then copied the entire text into my clipboard, ran
wc, and pasted it into
stdin. Next, I did a simple redirection that's supposed to have the exact same effect. But this is what I got:
$ wc[Enter] [paste 99010 lines of garbage copied directly from `big'] 99010 99010 10000010 $ wc < big 99010 99010 10000010
Notice the different field widths. My best guess is that the first result was printed with
"%7d %7d %7d", and the second with
"%8d %8d %8d".
Can someone please explain how this is possible? I'm of the impression that, as far as
wc is concerned, the input for the second experiment is coming from
stdin as well (because the shell takes care of
< big, so
wc shouldn't even know that I typed that), so theoretically
wc should have done the same exact thing twice, but it clearly did not. What am I not understanding about redirection?
Edit: I don't think this really matters, but I did
$ cat big | xclip -selection clipboard to copy the data into my clipboard, then I simply right-clicked in gnome-terminal and pasted it in. Just in case anyone wants to try this out on their computer.