Computing.Net > Forums > Unix > awk shell scripting

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

awk shell scripting

Reply to Message Icon

Name: evan108
Date: March 15, 2004 at 12:42:30 Pacific
OS: mac osx server
CPU/Ram: mac osx server 1.5 gig
Comment:

is it possible with awk or grep (or some other
unix tool) to stop the search of a text file after the
number of results reaches a predifined number.

I am searching rather large files and would only
like to capture the first 2000 or so results. Thus for
speed resons i would like awk or grep to brake
out of the loop when 2000 results are recieved.

any suggestions would be very helpful


thanks
-evan




Sponsored Link
Ads by Google

Response Number 1
Name: aigles
Date: March 15, 2004 at 13:21:27 Pacific
Reply:

With awk you can do something like this :

awk '/search_pattern/ { print ; if (--count == 0) exit }' count=2000 input_file


Jean-Pierre.


0
Reply to Message Icon

Related Posts

See More


silicon graphics os ftp/get command usage



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: awk shell scripting

Unix, Shell Script, awk & variables www.computing.net/answers/unix/unix-shell-script-awk-amp-variables/5148.html

Shell Script & Awk www.computing.net/answers/unix/shell-script-amp-awk/4594.html

awk in shell script www.computing.net/answers/unix/awk-in-shell-script/6200.html