more powerful grep – ack
For last couple of days, I have been using ack instead of grep. Here is description of ack:
Ack is designed as a replacement for grep.
There are couple of reasons I am using ack. First and foremost being it does not require a filename. So, for seaching amit in all files recursively under the current directory I can simply use
ack amit
More reasons to use ack:
It supports pager option and there can be a rc file that can be used to define the default options that needs to be used with ack. Here is the contents of my $HOME/.ackrc file.
–pager=most
–color
–sort-files
-u
-H
–context=3
–all
SO, basically when I do the search, the output is piped to most command and there are 3 context lines displayed for the search. The filename too is displayed for the search result and the output is colored. <span style="background-color: #ffffff;">There are other options used in the rc file, that you can see in the man page for ack.
Now if I had to do that with grep, I would need a function for grep or an alias but this is much cleaner. Ain’t it. What do you think, leave a comment to tell me.
You need to install ack with the following command:
sudo yum install ack