2 ms·
Yeah, there are still some edge cases where cat is useful, but more often than not I just begin the redirection. I reckon some don't realize you can put it at t
by jchw 2y ago
Yeah, there are still some edge cases where cat is useful, but more often than not I just begin the redirection. I reckon some don't realize you can put it at the beginning, which does sometimes feel more ergonomic in a pipeline.
- JoshTriplett 2y agoIt's not that it feels awkward to write the redirection first. It's that it feels awkward to write `< file cmd`, with no operator between the filename and the command, and the redirection operator not pointing at the command.
- jchw 2y agoTo me, the < and > redirections never point toward or away from the command. Rather, they point into or out of the file. And really that's because they do: like, >file is really 1>file, and <file is really 0<file. I think if your intuition on how redirections work is based on whether it points at the command it's worth rethinking how you look at redirections.
- kortilla 2y agoA pipeline without pipes connecting is just a field of shit
- MathMonkeyMan 2y agoIO redirection doesn't construct a pipe, but piping does. # Open foo.txt and use it as fd 0 in jq <foo.txt jq '[1,2,3]' # Create a pipe(). Use the write end as cat's fd 1 and the read end as jq's fd 0 cat foo.txt | jq '[1,2,3]' Best thing would be a directed graph where each node is a process or a file. A process has at most one edge going into it (stdin) and at most two coming out (stdout and stderr). A file has exactly one edge touching it. Hard to do in text, though. Would look like lisp.