ack + tool like grep (problem )

2

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

lidia

Posted 2010-09-07T11:02:51.763

Reputation: 629

Answers

0

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).

nik

Posted 2010-09-07T11:02:51.763

Reputation: 50 788

Even better than -a is --text. – Andy Lester – 2010-09-07T14:17:22.280

0

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.

Andy Lester

Posted 2010-09-07T11:02:51.763

Reputation: 1 121