I was originally of the impression that
$ ./myprog
moo[CTRL-D]
is exactly the same as
$ echo moo > cow
$ ./myprog < cow
But I found that myprog
always counts one more \n
in the second version than in the first. Why is this?
Turns out wc
does the same thing...
$ wc -l
moo[CTRL-D]0
(Apparently zero lines is possible?)
$ echo moo > cow
$ wc -l < cow
1
Can anyone explain this to me?