Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I provide Ack with the directory I want to search?

I would like to use the linux command line tool ack but there is one thing stopping me from using it and that is that I cannot figure out how to tell it where to start searching from. I would like to start to replace my complex find/xargs/grep commands with ack but if I cannot tell it where to start to search from I cannot use it.

For instance I am running a simulation in one directory but I would like to tell ack to search a code library from somewhere else without having to change to that directory to invoke ack.

like image 926
stephenmm Avatar asked Nov 05 '10 23:11

stephenmm


People also ask

How do you use ack?

Use the "-f" switch to see a list of files that ack will search for you. If you want ack to search files that it doesn't recognize, use the "-a" switch. If you want ack to search every file, even ones that it always ignores like coredumps and backup files, use the "-u" switch.

How do I navigate to a directory?

Navigate directories. Open a window, double-click on a folder, and then double-click on a sub-folder. Use the Back button to backtrack. The cd (change directory) command moves you into a different directory.

How do I search only directories in a specific directory?

You can use combination of ls command, find command, and grep command to list directory names only. You can use the find command too.


1 Answers

You can provide the directory as an argument; only if you give it zero arguments past your pattern will it look in the current directory instead of where you ask it.

ack MySymbol ../src 
like image 172
Brandon Rhodes Avatar answered Sep 22 '22 16:09

Brandon Rhodes