5 ms·
This is a serious question: Why would you want to use plain old "grep" instead of "ack"[1]? Of course, other than the fact that it's on all machines. Why would
by pooriaazimi 14y ago
This is a serious question: Why would you want to use plain old "grep" instead of "ack"[1]? Of course, other than the fact that it's on all machines. Why would you use it instrad of "ack" on your own machines? That's an honest question, I'm not starting a flamewar... The highlighting and filename/line# by default is the killer feature for me.
Edit: Come on. Downvotes for this? Honestly... It's HN, not StackOverflow. You don't mark questions as "off-topic" unless they're trolling...
[1]: http://betterthangrep.com http://betterthangrep.com
- pbhjpbhj 14y ago>Why would you want to use plain old "grep" instead of "ack"[1]? // First time I've heard of it. Thanks. Only been grepping my way around for the last dozen years or so ...
- audiodude 14y agoI love ack, I've never looked back.
- MattJ100 14y agoThe main reason to use grep is portability/availability. While a modern improvement to grep (yes, I'm an ack user and fan too) you can't simply depend on it in portable scripts and such. grep is defined for POSIX after all: http://pubs.opengroup.org/onlinepubs/009695399/utilities/grep.html http://pubs.opengroup.org/onlinepubs/009695399/utilities/gre... I also suspect (without looking) that there are obscure (but occasionally useful) grep features that ack doesn't support.
- greyboy 14y agoThat's a fine recommendation for machines that you solely work on, or have complete control over. However, it's good to be able to work with the standard toolset if you frequently work on a variety of remote machines (where it's quite common that you cannot install such things, due to permissions or policies, and want to get started working before attempting to download/install a bunch of custom binaries). Edit: MattJ100 made a more clear point while I was responding.
- pooriaazimi 14y agoThanks for the response. However, a nice thing about ack is that it's not a binary (necessarily) - it's a perl script and can be used without sysadmin permissions: http://betterthangrep.com/install/ http://betterthangrep.com/install/ The other points are quite understandable and correct though. It's always best to at least be familiar with standard tools, even if you want to use an slightly different version for yourself.
- greyboy 14y agoI think we're probably mostly in agreement, even if I wasn't clear about it. In my line of work, there have been times where I was not permitted to use external scripts or binaries (highly sensitive environments). However, that one small example doesn't mean ack should be disregarded!
- eliasmacpherson 14y agoack has ignore built in for certain filetypes. Then combined with my shell expanding * to just the files and directories at the current layer, ack will not find certain things that grep -R string * will.
- a3_nm 14y agoack-grep is a good tool to grep through files. grep is more than that. When I need to grep in a pipeline, I probably don't want ack-grep's bells and whistles. One example of a useful feature of grep: "grep --line-buffered" to grep with no buffering in a pipeline.
- benatkin 14y agoIt's called ack. Ubuntu gave its package and executable a different name because it conflicted with something far less notable (poor choice IMO). I suggest adding an a alias or a symbolic link so you can call it by its proper name when typing in commands.
- haakon 14y agoUbuntu didn't; debian did. Ubuntu just inherits that. Perhaps eventually they will fix it, which they did for git (which was once git-core because of a conflict with a less notable package).
- jasomill 14y agoBecause it motivates me to avoid revision control systems that insist on crudding up every directory in my source tree?
- coned88 14y agoBecause perl regex is really quite slow http://swtch.com/~rsc/regexp/regexp1.html http://swtch.com/~rsc/regexp/regexp1.html
- ghshephard 14y agoI've been a systems administrator of one form or another for 19 years, spend 2-3 hours a day on the CLI, and I've never heard of ack. Depending on the time of day (and platform) i might use grep or egrep. I hopped onto one of the random ubuntu boxes I own, did a quick "apt-get install ack; man ack" - here is what it said: "ACK is a highly versatile Kanji code converter. ACK can do reciprocal conversion among Japanese EUC" This is probably why I don't use ack - never heard of it, not available on any system I use, and the dpkg repository has something that has nothing to do with grep. Enough of an answer?
- ksherlock 14y agodebian installs it as "ack-grep".
- csense 14y ago> Why would you want to use plain old "grep" instead of "ack"? 1. Because all the cool kids are doing it. 2. Because I hate Perl.
- koenigdavidmj 14y agoWhy is your Perl hate relevant? It can be written in COBOL for all I care; I'm just using a tool to find files. I don't spend my days browsing through the source code of random tools.