Hacker News new | ask | show | jobs
by jfhufl 2875 days ago
One good reason (IMO) for doing "cat file |" is it's easier to grab the command from your history and change it to something like "grep foo file |" rather than if you had run "cmd < file".
2 comments

Also, if you have a long pipeline:

  cat file | this | that | other | out
  vs
  this < file | that | other | out
In the cat example, it's easy to change the head of the pipeline, by adding things before "this" or deleting "this", which is less so in the non-cat example. (The use case I have in mind is experimental commands that take probably <10s to complete, where editing time is a significant fraction of the time you spend.)

  < file  this | that | other | out
My counter argument would be that with a good shell line editor like zsh in vi mode command transformations are as cheap as modular grammar; however I know there's limits to that argument (Java is only writeable in Java IDEs) so I'll grant you that :-)