Hacker News new | past | comments | ask | show | jobs | submit login

It can crash, on large files, particularly on macOS because mmap is disabled by default.

But that should go away by streaming the file. e.g.

    cat haystack | ag 'Needle'



    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.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: