Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.