grep is a command-line tool for searching text patterns in files.

learn more… | top users | synonyms

4
votes
3answers
57 views

Extracting the date of the latest message from an mbox file

How would I go about extracting the "Date:" header for the latest received message in an mbox file? Note that it's not simply an issue of grep'ing for the latest occurrence of "^Date:", since it ...
2
votes
3answers
208 views

How do I make grep results colored?

I have some output of my program: # php check.php | grep -E "rule_1|rule_4" I would like results equaling to rule_1 to be red and results equaling to rule_4 to be blue. Is this possible, because at ...
4
votes
2answers
156 views

How do I programmatically convert putty logs to human-readable, searchable files?

Background: I have a Windows 7 workstation and use PuTTY for SSH connectivity to Linux servers with session logging enabled. I previously used the Printable output option but that has the benefit of ...
2
votes
2answers
103 views

Script to email if grep result is null

its been a long time and I cant seem to remember how to do this. I am trying to grep a logfile for a word or words and email if it does not exist in the last fifteen minutes ( I will be setting a cron ...
1
vote
2answers
113 views

Update grep on Ubuntu through apt

Say, I currently have grep version 2.2 on my system and I would like to upgrade to version >= 2.5. Other than installing grep through source code, is there a method to update grep using Ubuntu (apt) ...
0
votes
2answers
190 views

find and replace multiple files using a file as input to find and another to replace

I need to replace several chunks of text inside some php scripts... i have: find . -name 'products.php' -exec grep --silent 'TEXT_TO_FIND' {} \; -exec ls {} \; -exec sed -i 's/TEXT_TO_FIND/...
0
votes
2answers
74 views

grep double quote in cron

i run this command on the terminal $ my_json_generator.rb | grep \"mtype\":164 | my_json_consumer.rb json_generator creates json objects. 1 per line. {"foo":7, "mtype":164, "bar":[1,2,3]} I ...
0
votes
2answers
1k views

grep, count and sort iptables log to get IPs qty and DPT?

How can I grep count and sort iptables log to get IPs quantity and DPT? Like I used this oneliner to get top IP quantity. egrep -w "Invalid Packet" ipfirewall.log | grep -o '[0-9][0-9]*\.[0-9][0-9]*\...
2
votes
1answer
212 views

Logcheck: wildcards which include non-latin characters

On my mail server, I have a custom logcheck rule as follows, which is intended to filter messages from deliver: ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ deliver\.*\): msgid=.*: saved mail to.*$ ...
1
vote
1answer
61 views

How to write a shell script to search from a position in file instead to start from beginning of the file again

I am trying to write a shell script to find value stored after a repetitive word in a big file with millions of lines using for loop. After the finding the repetitive word how i make script to start ...
1
vote
1answer
610 views

recursive grep started at / hangs

I have used following grep search pattern on multiple platforms: grep -r -I -D skip 'string_to_match' / For example on FreeBSD 8.0, FreeBSD 6.4 and Debian 6.0(squeeze). Command does a recursive ...
0
votes
1answer
14 views

how to compare and move the matched string files in different locations

I have a two different .zip files in /tmp/1/ and /tmp/2 I want to compare these two different location files and move the matched string files into /tmp/3 /tmp/1 ArchiveFile_aaa.zip ArchiveFile_bbb....
0
votes
1answer
19 views

grep the result of cdrecord or wodim

I would like to parse the result/progress of a running cdrecord -v burn process. What I tried so far was cdrecord -v dev=/dev/sr0 -data foo.iso 2>&1 | grep -E 'Track [0-9]+:.*written'. ...
0
votes
1answer
37 views

shell script to grep within range inside of cron

I'm trying to create a shell script that would look for ERROR inside of /var/log/jbossas/standalone/server.log, such as following: # grep ERROR /var/log/jbossas/standalone/server.log 10:36:37,530 ...
0
votes
1answer
36 views

Is there a tool for indexing a directory in order to perform cheap content search? (hashing by word, for example)

I am often using grep -R on an entire directory tree to find all files that contains a specified word. I wonder if there is a tool that makes the whole operation much faster, maybe via hashing? (Unix ...
0
votes
1answer
322 views

Using grep -Po to extract regex

I've been struggling with "grep -Po" off and on for a couple hours. What I would like to do is to find out how many bytes the virtual disk size is as reported by qemu-img info. Here's example output:...
0
votes
1answer
281 views

Regex matching specific details if first match exists, multiline

I'm struggling to get the correct regex to match specifically 'Contact' and 'User-Agent' only if the 'Contact' address matches 10.0.x.x in ~70GB of SIP messages. The SIP message will always contain a ...
5
votes
0answers
201 views

grep is inconsistently defaulting to grep -P?

I have a script that does some housekeeping that works perfectly well when invoked from an interactive shell, but did nothing when invoked by cron. To troubleshoot this I started a shell with a 'blank'...
1
vote
0answers
544 views

How to define mail from and host settings in Websphere 6.1 for Java application

Working with some older WAS 6.1 hosts (fix pack 25), and have a java app that sends mail from one host with a mail from field: nobody@nosuchhost.nosuchdomain.com [mailto:nobody@nosuchhost....
0
votes
0answers
101 views

Nginx - change status code based on grep of process list or similar

We are using nginx as a reverse proxy in our cloud infrastructure, and it's pretty handy. I'd like to use it for something else though. On some of our VMs, there is a process that I need to be able ...