by kazinator · 2y ago · 0 comments
< access.log head -n 500 | grep mail | perl -e
Now you can delete "head -n 500 |".> If we then delete only the head processing step we’re left without a step that transforms the string access.log into the contents of the access log.
By introducing "cat access.log" we have the same problem: if we delete only the cat processing step, we're left without a step that transforms the string access.log into the contents. For the useless cat to have the nice property that you can cleanly delete it from the command line, you need:
< access.log | cat | head -n 500 ...
:)It should be the same as giving your pipeline a file input handle via < access.log… but why take the risk?
$ echo "foo" > access.log # create the access.log with some content
$ < access.log | cat | head -n 5
# no output
This works: $ cat access.log | head -n 5
foo
$ < access.log cat | head -n 5
foo
$ < access.log cat | cat | head -n 5
foo
$ < access.log head -n 5
foo