Ack2 is a greplike tool. Accordingly to documentation it's primary purpose is for searching large amount of content data like source-code of projects.

There is a great comparison chart on ack2 authors site that I recommend to check!

To The Point

Docker for building ack2

So as I'm a docker-fan-boy as usually I decided to check if this tool will work, but not on my host machine, but using docker first with a ubuntu:trusty docker-image.

I've created a Dockerfile like that:

FROM alpine:3.6
RUN apk add --update
RUN apk add --update perl && rm -rf /var/cache/apk/*
RUN apk add --update wget && rm -rf /var/cache/apk/*
RUN apk add --update tar && rm -rf /var/cache/apk/*
RUN apk add --update curl && rm -rf /var/cache/apk/*
RUN apk add --update make && rm -rf /var/cache/apk/*
WORKDIR /app
RUN curl -o ack2.tar.gz https://codeload.github.com/beyondgrep/ack2/tar.gz/2.23_02
RUN tar -zxvf ack2.tar.gz
WORKDIR /app/ack2-2.23_02
RUN perl Makefile.PL
RUN make
RUN PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install File::Next'
RUN make test
RUN make ack-standalone
RUN cp ack-standalone /bin/ack2
CMD ["ack2"]

Run with docker build -t anselmos/ack2:2.23_02 -f Docker.alpine.latest . and checked for building to be done.

Ack on Docker alpine

There is an alpine version of ack but only on edge version and the ack version is 2.18. I used this Dockerfile to check it:

FROM alpine:edge
RUN apk update
RUN apk add ack

With docker build -t anselmos/ack2 -f Dockerfile_alpine . And then docker run -it anselmos/ack2:alpine

Installation

There is also a much more simpler way that is described here.

For ubuntu you run:

sudo apt-get install -y ack-grep 

And you can create a soft link for calling ack not ack-grep with:

sudo dpkg-divert --local --divert /usr/bin/ack --rename --add /usr/bin/ack-grep

For Ubuntu:Trusty it's 2.12 version.

Usage

To use ack check this documentation - contains all the reference - also I encourage you to check ack2 --help to see what type of flags there is.

The output from ack2 is a bit different from grep, and it's more readable than on grep.

ack2 "perl" *.md

And it will search for "perl" in all .md extension files.

Acknowledgements

Auto-promotion

Related links

Thanks!

That's it :) Comment, share or don't - up to you.

Any suggestions what I should blog about? Post me a comment in the box below or poke me at Twitter: @anselmos88.

See you in the next episode! Cheers!



Comments

comments powered by Disqus