4 ms·
The gotcha is perhaps failing to recognize that cat will actually fail in this simple pipeline because its output is truncated "unexpectedly" by head exiting af
by tux1968 6y ago
The gotcha is perhaps failing to recognize that cat will actually fail in this simple pipeline because its output is truncated "unexpectedly" by head exiting after completing its job properly. (Maybe you could argue that head should be a good citizen and read its input to completion)
Where this will work as expected:
bash -eo pipefail -c "head < /etc/services -1|cat ; echo got here"
- gray_-_wolf 6y agoBut head is a being a good citizen by doing only what it needs to do and not anything else. Otherwise things like `grep X <5GBfile | head -n1` would process the whole file and not just until the first match.