There are lots of utilities that can emulate grep. Few, if any, of them will be faster or use less memory than grep for the options you're using. Since you're using fixed strings rather than regular expressions, you could make grep run faster by using the -F option. But, you didn't mention searching compressed and/or gzipped files until post #7 in this thread. Uncompressing or unzipping a file and searching the converted plain text is obviously going to take a LOT more memory and/or swap space and a LOT more time than searching a plain text file.
The fact that you're processing your compressed files, your gzipped files, and your plain text files with:
and processing your plain text files with names containing .trace again with:
probably won't affect swap space, but it will make processing the files in your directory take longer.
If you have the space, you'd be better off keeping your log files uncompressed until you're done searching them. With uncompressed, unzipped files, grep shouldn't need a lot of memory or swap space. I have no idea whether zgrep takes a lot more memory and swap, but I wouldn't be surprised if it does.
If you want to search for two (or more) patterns in all of your log files, it will take a minuscule bit more space and run a LOT faster if you combine them in a single invocation of grep.
For example:
If the zgrep commands really are taking too much swap, you might need less if you uncompress your compressed files, gunzip your gzipped files, grep the files you uncompressed and unzipped, and then compress or gzip them again. (But, that will be slower, and uncompress and gunzip may eat up as much swap as zgrep.)
I have multiple strings in a file which have special character $, when i search strings by ignoring $ with \ using single quotes it returns empty results.
My search strings are set char_1($lock) and set new_char_clear_3($unlock)
I tried searching with
but it returns empty results.However... (3 Replies)
Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried:
grep -lr "this string" *
but I do not... (3 Replies)
Hello,
I have two files. All urls are space seperated.
source
http://xx.yy.zz http://df.ss.sd.xz http://09.09.090.01
http://11.22.33 http://canada.xx.yy http://01.02.03.04
http://33.44.55 http://98.87.76.65 http://russia.xx.zz
http://aa.tt.xx.zz http://1w.2e.3r.4t http://china.rr.tt
... (4 Replies)
Hello,
What I wish to attain is:
- to read fileA line by line
- search entire line as string in fileB
- when found, grep the next line in fileB
- then merge "searched line" and "found line" in a new file, fileC
Here is my fileA:
T S Eliot
J L Borges
L Aragon
L L Aragon
T S Eliot 4 0... (17 Replies)
Hi Folks,
I have a log file at the following location..
/opt/ert/abc.log
Now abc.log contain the following enteries in this format below..
23-Jul-2014 10:09.32.204 ERROR abc.log cdfrer tyre fgty >>>>> cqno : 78539132 abc Id : 0 Sabc : 20140724
Now in log file (abc.log) I want to... (2 Replies)
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
I have requirement to prepare script which will grep for latest outofmemory message from the logs. I have used following command to grep the string from the logs,this script is not effective when logs are not getting updated as it will grep for old message.
f=catalina.out
var=`tail -10 $f |... (17 Replies)
Hi,
I am trying to grep a particular string from the files of 2 different servers without copying and calculate the total count of its occurence on both files.
File structure is same on both servers and for reference as follows:
27-Aug-2010... (4 Replies)
Hi frnds
i want to desplay file names that should be word1 and word2
ex :
i have 10 *.log files
5 files having word1 and word2
5 files having only word1,
i have used below command
egrep -l 'word1|word2' *.log
its giving all 10 files, but i want to display only 5... (20 Replies)
Hi all,
Please help me in the following dbt
i want to know the different files in the current and the sub directory which have some search key in that . for example
i want to know all filenames followed by the word 'unix' in all files.
the file name and the matching word have... (1 Reply)