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

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 
share|improve this question

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.

share|improve this answer
see – 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
up vote 0 down vote accepted

I find the solution

need to write:

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

You must log in to answer this question.

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