Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    ag Needle < haystack
No need for cat


Your version requires fewer keystrokes. It's also mental model-breaking and un-Unixy. Pipes, my good man! Pipe everything to everything!


How come knowing how to redirect stdin is un-Unixy?

Pipes are a good tool, and so are many others. Having a good command of other basic mechanisms of the shell is going to hugely pay off, try to have a brief shot if you want [0].

[0] https://www.gnu.org/software/bash/manual/html_node/Redirecti...


No. Useless Use of Cat is sufficiently unidiomatic that there is an award for it:

http://porkmail.org/era/unix/award.html


No. Being smug doesn't make someone right. Especially when the smug person is advocating a special case. Special cases are inherently wrong, even when they "save" a process.


If the most logical syntax is

  grep needle haystack
Surely

  grep needle < haystack
is much closer to that form than

  cat haystack | grep needle


Mm, input redirection with the shell is the very epitomy of basic Unix functionality.


< haystack ag Needle

Will work too, and now it's in the logical order.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: