I have to grep from a file (5MB) containing specific strings the same strings (and other information) from a big file (27GB). To speed up the analysis I split the 27GB file int
My initial thoughts are that you're repeatedly spawning grep
. Spawning processes is very expensive (relatively) and I think you'd be better off with some sort of scripted solution (e.g. Perl) that doesn't require the continual process creation
e.g. for each inner loop you're kicking off cat
and awk
(you won't need cat
since awk
can read files, and in fact doesn't this cat
/awk
combination return the same thing each time?) and then grep
. Then you wait for 4 greps
to finish and you go around again.
If you have to use grep
, you can use
grep -f filename
to specify the set of patterns to match in the filename, rather than a single pattern on the command line. I suspect form the above you can pre-generate such a list.