subject ack utility

I don't sure if it possible but I must to ask the following question Because I have a big problem -

I use the ack utility to find string in very very very large files

The problem is when ack find the string in the file , but ack continue to search the same string until end of the file

my question is if it possible to stop search in the file when the first string was found ?

My problem is that ack take allot of time because the biggest files

any way my target is only to find the first match string and get out immediately from the file to other files

can some on have creative idea how to use ack as I explained ?

  ./ack -a some_string  /var 
link|improve this question

79% accept rate
feedback

2 Answers

up vote 0 down vote accepted

I find the solution

need to write:

  ./ack -a --max-count=1 some_string   /var 
link|improve this answer
Or just use the shortened version of that: -1 – Andy Lester Mar 8 '11 at 16:49
feedback

The only ack that i found is the Kanji converter - is that what you mean?

grep can do the job and you can stop it whenever you want.:

Here is the appropriate option:

-m NUM, --max-count=NUM
 Stop  reading  a  file  after  NUM  matching  lines.

You can use it as follows:

grep -m 1 some_string file_name

Check out the man page of grep for more details.

link|improve this answer
see betterthangrep.com – jennifer Oct 6 '10 at 12:53
I want to do the same with ack is it possible , I cant use grep because grep is not power tool as ack – jennifer Oct 6 '10 at 12:55
feedback

Your Answer

 
or
required, but never shown

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