2 ms·
I suppose this is a similar situation as with `cat' - it's meant to conCATenate stuff, but the most common usage I've seen (and one I've learned) is the idiom o
by TeMPOraL 9y ago
I suppose this is a similar situation as with `cat' - it's meant to conCATenate stuff, but the most common usage I've seen (and one I've learned) is the idiom of `cat somefile | some-commands'.
(Whenever I share a snippet with this idiom, I get told by one of my cow-orkers to stop abusing kittens...)
- klez 9y agoIsn't `some-command < somefile` more idiomatic (also, should spawn one process less)?
- aepiepaey 9y agoYes. See "Useless use of cat" (or "UUOC"). If you prefer to have the command arguments at the end of the line (so it's easier to amend), you can do e.g: < file.txt grep pattern instead of grep pattern file.txt or cat file.txt | grep pattern There are also some related useless uses, like useless use of grep | awk: grep pattern file | awk '{print $3}' which can instead be written as awk '/pattern/ {print $3}' file