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

learn more… | top users | synonyms

2
votes
3answers
190 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 ...
1
vote
2answers
116 views

The meaning of * in Basic regex versus Extended regex

I thought * meant zero or more of the character or class that precedes it in basic or extended regex. Why does echo hello| grep '*llo' fail but echo hello |egrep '*llo' succeed?
0
votes
2answers
94 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 ...
0
votes
2answers
62 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 ...
2
votes
1answer
169 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
295 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
57 views

How to grep a continuous stream, with paging

I posted this to Superuser but got no takers: http://superuser.com/questions/832578/how-to-grep-a-continuous-stream-with-paging I want to take a log file and filter out some irrelevant log entries, ...
0
votes
1answer
34 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
160 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 ...
0
votes
1answer
705 views

Grep mail log for sender email and date

I am trying to grep the mail log in Plesk using Terminal on my Mac to find the issue with an email being sent from an external email to my client's email addresses. The issue started about two weeks ...
0
votes
1answer
227 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 ...
0
votes
1answer
690 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 ...
1
vote
0answers
80 views

linebreaks between results in grep

I need to occasionally monitor a spider that I have running on my server. I'm testing it to see how many iterations of it are running concurrently and to see if any of them are hanging. I use this: ...
1
vote
0answers
101 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 ...
1
vote
0answers
318 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 ...
0
votes
0answers
44 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 ...
0
votes
0answers
38 views

Refine grep look behind to avoid numbers

When I query docker images, I get this: #> docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE local/debian 7.5 172c7702a46f ...
0
votes
0answers
208 views

Different result with same grep conditions via ssh

Like in the subject I got different result from the same grep command. The following command is run on a central server which query the other servers via ssh. ssh root@$domain "grep `date +%Y/%m/%d` ...