ack on solaris – grep recursively.
2010-06-25
236 words
2 mins read
<span style="background-color: #ffffff;">Some days back I posted an article on ack <a href="http://blog.amit-agarwal.co.in/2009/08/24/more-powerful-grep-ack/" target="_blank">here. Today I was working on Solaris 9 and the default grep installed on the system does not have the ”-r” option to search recursively. So, you know for all the time I had to keep using find with grep to work with directories recursively. This was something similar to the one below:
<span style="background-color: #ffffff;">find . -type f -exec grep amit {} \;
<span style="background-color: #ffffff;">or with useless use of cat command:
<span style="background-color: #ffffff;">find . -type f -exec cat{} \; | grep amit
<span style="background-color: #ffffff;">This is okay to make one or two searches but not that easy to keep typing and I already have too many aliase’s to have one more added to the list. So, I tried to use the ack command on the Solaris box, knowing full well that the command is written in perl and BINGO.
<span style="background-color: #ffffff;">There’s not much you need to do to get ack working on Solaris. Here’s what you need to do:
<span style="background-color: #ffffff;">Copy the ack command to one of the paths in the PATH.
<span style="background-color: #ffffff;">ack needs App/Ack.pm.
<span style="background-color: #ffffff;">Ack.pm needs File/Next.pm
<span style="background-color: #ffffff;">So, you copy these two files from any installation and then copy them to one of the paths mentioned in the output of ”perl -V”. Done.
<span style="background-color: #ffffff;">Wasn’t that easy.
<span style="background-color: #ffffff;">
Related Articles:
- 2010/06/11 for loop in bash script on solaris without seq
- 2010/05/26 more powerful grep – ack
- 2010/05/19 Solaris Tips and Tricks
- 2010/05/12 Linux tip to find the pid/program using a particular port
- 2010/05/06 View entire process string
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.