4 ms·
that’s a lesson that’s no longer applicable on modern machines I think? —- it often makes sense to start a sequence of piped commands with a cat invocation. One
by Myrmornis 4y ago
that’s a lesson that’s no longer applicable on modern machines I think? —- it often makes sense to start a sequence of piped commands with a cat invocation. One reason is that then the order of sources and sinks in the command syntax matches reality.
- samatman 4y agoI always pipe from cat, as a matter of habit. Reason being: I've probably just catted the file at least once, and it's even likely I catted it right before piping it. So I can extend that command from the history, and if I keep piping (likely) I don't have the weird syntactic stutter at the beginning where `blah < file.txt` | next` puts things out of order. Also, you can't mistype `cat file.txt | blah` and overwrite file.txt accidentally with the output of blah. That's ergonomic.
- gnubison 4y ago‘<file.txt blah’ works just fine.
- fomine3 4y agoIt's preference, like Python list comprehensions vs Ruby method chain.
- rotifer 4y agoI often use cat because when constructing a pipeline I'll do multiple rounds of: head filename | ... Once its working I find it easy to just type C-aM-dcat (i.e. beginning-of-line kill-word cat).
- samatman 4y agoThanks for the reminder (sincerely) but to me this is worse, I would use a shell which doesn't offer this particular form of irregular grammar, I hate it. 100% aesthetic, I shouldn't be able to point a file at my prompt and have it end up streamed into the next word. Just awful, 0/10, do not want.
- gnubison 4y agoFrom another perspective it’s more regular that position doesn’t matter. (This behavior works in all POSIX shells, zsh, rc, etc. But not fish :p)