Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a directory listing as follows (given by ls -la):

total 8
drwxr-xr-x   6 <user>  <group>  204 Oct 18 12:13 .
drwxr-xr-x   7 <user>  <group>  238 Oct 18 11:29 ..
drwxr-xr-x  14 <user>  <group>  476 Oct 18 12:31 .git
-rw-r--r--   1 <user>  <group>  601 Oct 18 12:03 index.html
drwxr-xr-x   2 <user>  <group>   68 Oct 18 12:13 test
drwxr-xr-x   2 <user>  <group>   68 Oct 18 12:13 test2

Running ack . -f prints out the files in the directory:


How can I get ack to print out the directories in the directory? I want to ignore the .git directory (which I understand is default behavior for ack). On that note, how can I ignore certain directories?

I am using ack 1.9.6 on Mac OSX 10.8.2.

share|improve this question
Why do you want to use ack to list things instead of ls? – Alan Shutko Oct 18 '12 at 16:51
I need something I can readily pipe into xargs. My options are find --print0 (weird syntax, trying to stay away from it) and ack --print0, both of which readily pipe into xargs -0. – KPthunder Oct 18 '12 at 16:56
So how is ack --print0 less weird than find -print0? If you find a command hard to type/remember, make an alias. – grawity Oct 18 '12 at 16:59
find . -name .git -a -type d -prune -o -type f -print0 simplifies to ack . -f --print0. Likewise, I want to find a way to simply find . -name .git -a -type d -prune -o -type d -print0 into its ack equivalent. – KPthunder Oct 18 '12 at 17:09
up vote 0 down vote accepted

You can't. ack is only for files, not directories. It is a text search tool, not a general purpose file finder.

To ignore directories, use the --ignore-dir option.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.