Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 use the ack tool to find string or IP address in file system

but please see the follwoing

why ack not find the IP = 10.45.45.130 under /etc/sysconfig/*

the IP = 1:10.45.45.130 exist under network dir in uoo file

lidia

./ack -r 10.45.45.130  /etc/sysconfig/*
   <not get anything?>

./ack -r 10.45.45.130  /etc/sysconfig/network/*
 /etc/sysconfig/network/uoo
 1:10.45.45.130

example of uoo file

 more /etc/sysconfig/network/uoo
 10.45.45.130
share|improve this question
up vote 0 down vote accepted

Did you try 'ack -a'?

From BetterThanGrep,

 -a, --all-types       All file types searched;

Option -r is not required (afaik) default behavior is recursive.
To turn off recursion you use the '-n' option.

Now, to check if the '-a' is going to help you,
Try your command with the '-l' option (instead of the '-r' option).
Then try it again with the '-L' option.

You will figure what is going on based on where the 'uoo' file shows up in your search results.

Here is what happens,

-l, --files-with-matches
                        Only print filenames containing matches
-L, --files-without-matches
                        Only print filenames with no matches

So, if your file does not show up on either of these forms, you need to add in the '-a' option
(ack is more powerful than grep but its also a bit tricky).

share|improve this answer
    
Even better than -a is --text. – Andy Lester Sep 7 '10 at 14:17

By default, ack goes on whitelists of filetypes. If ack doesn't see the file as a certain type, then it ignores it.

Ack is really a programmer's tool, not a sysadmin tool.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .