How to install ack-grep 2.0 with apt-get?

You can't install yet ack-grep 2.10 using apt-get because ack-grep 2.10 is not yet included in Ubuntu repositories. To see what versions are available in repositories, you can use the following command:

apt-cache showpkg ack-grep

But you can install by downloading it from here:

  • http://packages.debian.org/sid/ack-grep

It's a deb file, so you can be interested also by:

  • How do I install a .deb file via the command line?

If you are using Ubuntu 13.10, then you can install ack-grep 2.04.2 using the Ubuntu Software Center. The ack-grep package is from the universe repository. ack-grep is a meta package to pull ack in 18.04 and later. Run sudo apt install ack and execute ack instead of ack-grep.

To give an example of what ack-grep can do, here is a command to display eight lines from somewhere in the middle of the bash manual, which is larger than 300Kb, and therefore it is inconvenient to find a referenced line number in the bash manual by scrolling down in the terminal, but it's easy to do with ack-grep:

man bash | ack-grep . --lines=4581-4588

...gives the following block of text from the bash manual as output:

pwd [-LP]
       Print the absolute pathname of the current working directory.
       The pathname printed contains no symbolic links if the -P option
       is supplied or the -o physical option to the set builtin command
       is enabled. If the -L option is used, the pathname printed may
       contain symbolic links. The return status is 0 unless an error
       occurs while reading the name of the current directory or an
       invalid option is supplied.

The command that is equivalent to the above command in 18.04 and later uses ack instead of ack-grep and different line numbers because the bash manual is longer in 18.04. ack works the same as ack-grep and outputs the same results:

man bash | ack . --lines=4970-4977

You don't have to wait for saucy (Ubuntu 13.10) to be released to use its version of ack-grep. You can install just one package, and its unmet dependencies, from a future release with the right apt-pinning preferences.

See these examples:

Install packages from newer release without building (apt pinning)

Install a single specific package from future distribution