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

learn more… | top users | synonyms

1
vote
1answer
32 views

Finding strings in files with relative path

I don't understand why this two commands don't provide the same result (the differrence is only relative vs. absolute path), can somebody explain it? annika /srv/www/pages/com.example.www/www/povruc ...
1
vote
1answer
75 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, ...
12
votes
3answers
825 views

grep behaving differently on Fedora vs Ubuntu

So when I run this in Fedora I'm seeing this: $ ls hmm_data/indivA12_AATAAG/refs/par1/ 2R-orths.alleles 2R-ref.alleles $ ls hmm_data/indivA12_AATAAG/refs/par1/ | grep -F '-ref.alleles' ...
0
votes
2answers
46 views

Tail grep what tools are for it

I would like to run the following command: tail -f /var/log/syslog | grep -ri 00:16:CB:1E:AF:CA In Linux but it does not working. How would you interactively grep certain text from log files?
0
votes
0answers
50 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 ...
1
vote
1answer
58 views

Regex matching first word and any word

I have a log file with a list of many entries. With grep regex I want to match the first word and another word which can be anywhere in the string. For example, if I specified "user1" the search ...
5
votes
1answer
246 views

screen causes “tail -F | grep” to echo unmatched lines

This is Ubuntu (3.13.0-29-generic #53), trying to do a simple bash script to monitor a log file for matching lines. If I do the following, there is no output in the bash shell except for matches, ...
3
votes
1answer
145 views

Need help grepping postfix log

I'm trying to search for an unknown string (Message ID) in a log based on a known string (recipient address), and then grep the unknown string to output the entire relevant log information. I'm able ...
0
votes
2answers
96 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 ...
-1
votes
2answers
165 views

Parse Apache logs for specific verbiage within the last hour

I'm looking to parse my /var/log/httpd folder which contains a lot of Apache log files. I'm looking for specific events within the last hour. I've tried the below, but I didn't have any luck. grep ...
2
votes
4answers
50 views

Equivalent of grep -l for filenames in zipfile

Given a set of zip files, is there an easy way to list only those zipfiles that contain files whose names match a given pattern, cf. using grep -l to list only files whose contents contain lines ...
0
votes
0answers
39 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 ...
1
vote
2answers
38 views

How to report filenames found by strings after being piped through grep?

I've been around *nix long enough to remember having done this in the past, and now those neural pathways are gone... I'm searching /usr/local/lib for files that contain img_convert because I'm ...
-3
votes
1answer
113 views

Plesk Unable to exec utility listmng: Cannot find grep program System error 2: No such file or directory [closed]

I have a little problem with my plesk installation at the moment and unfortunately do not have enough knowledge to solve it on my own. I would therefore be glad if I could get a hint on this. I tried ...
0
votes
2answers
170 views

Bash/grep: ignore lines over N characters

I have a find/grep command that i use to search my projects' codebase, thus: find folder1 folder2 folderetc -print | awk '{print "\""$0"\""}' | xargs grep -n "search-string" Something that ...
0
votes
2answers
751 views

Capture piped multiline grep output into a variable

I'm using Zabbix's zabbix_sender.sh script to push exception stack traces to my remote Zabbix monitoring server. zabbix_sender.sh requires a key and a value for any data that it sends. It can read ...
1
vote
1answer
323 views

Get some meaning from apache logs with awk and grep [duplicate]

I am trying to have some meaning from my apache log files: I want to parse my access log and have some statistics about 200 status code hits (how many times each of them was hit). So I tried to learn ...
0
votes
1answer
44 views

How to comma-demilit the output from cut?

So far, I have this: grep -B 36 'pattern1' Mapper.1.Configuration.MapRules | grep "pattern2" | cut -d'"' -f2 which give me a new-line delimited list of values that I need. I could put this into a ...
1
vote
1answer
358 views

Sieve: filter subject with regex, file into mailbox named match

I am trying to filter mails by subject with a regular expression. The subjects I want to match are read like [git-foo] some more text where foo is the string I want to check for. I end up with the ...
0
votes
1answer
72 views

Invalidating email addresses from sql dump before import

Synopsis I would like to import production data into the development environment so testing can be done in an almost accurate way. Of course I need to invalidate e-mail addresses as I don't want ...
3
votes
1answer
32 views

How to find file which have not specific content?

I have a lot of files which already have SPF records defined grep -i v=spf *.db /var/named/domain.com.db domain.com. 14400 IN TXT "v=spf1 +a +mx +ip4:XXX.XXX.XXX.XXX ?all" And want ...
1
vote
0answers
85 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 ...
7
votes
5answers
424 views

Grep-ing gzipped files [duplicate]

I have a set of 100 log files, compressed using gzip. I need to find all lines matching a given expression. I'd use grep, but of course, that's a bit of a nightmare because I'll have to unzip all ...
0
votes
1answer
35 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
47 views

indexing logs for fast repeated grep/search

I have sets of verbose logfiles that in the course of solving a problem, I will repeatedly regrep. I usually have about 1-10GB sets of 50-150 files, that I'll spend a few hours with and then never ...
1
vote
4answers
3k views

How to properly pipe find with grep and cp in this use case

I am interested in recursively grepping for a string in a directory for a pattern and then cp'ing the matching file to a destination directory. I thought I could do something like the following, but ...
1
vote
2answers
159 views

Deleting inserted content in multiple files on linux server

I often have problem with sites that get hacked. Usualy they end up with inserted script in different files. Is there a way, on linux, to search for this content and automaticaly delte it ? Usualy ...
1
vote
1answer
73 views

Centos locate file in binary file

I have ran a command to find a string in files on the server like this: cd / grep -r "string to be found" * And the server returned some results like this Binary file ...
-1
votes
2answers
424 views

how to check null value in grep command using in shell script? [closed]

In shell script in centos, i write following 2 lines cmdread="Myprogram" kill -9 `ps ax | grep $cmdread ` But some times when manually myprogram stopped then my shell script give me warning that ...
2
votes
2answers
535 views

How to grep IP address and number of access

I am using the following command to get the number of hits of an IP address: grep "21/Jul/2013:22" /var/log/ispconfig/httpd/*/access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":"$3}' | sort ...
0
votes
2answers
68 views

Looking for a shell command to read non-binary part of most common image types

A website I'm hosting on my dedicated server has been hacked. Some pictures have been infected with things like <?php eval(base64_decode(....));?>. I'm looking for a generic shell command which ...
0
votes
2answers
378 views

GREP find and use SED to replace string on all files

One of our old hosted Joomla sites suffered a JavaScript injection, and im going through cleaning it up. The following code was inserted into every .php or .js file: <? #0c0896# echo " <script ...
0
votes
1answer
168 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
2answers
218 views

Getting Running Script Names Via PS

I need to get a list of all running PHP scripts but piping PS thru grep just gives me a list of all references to PHP files How do I accomplish this? Is this even possible? ...
1
vote
2answers
391 views

Why does grepping ps [p]rocess_name exclude grep from the results

A cool trick that saves you from having to use grep -v when grepping ps output (yes I know pgrep exists) is to put the first letter of the process into a character class like ps -ef |grep [s]vn. This ...
1
vote
2answers
868 views

How to find files that don't contain a given search string

I have a command that finds all the PDF files that contain the string "Font" find /Users/me/PDFFiles/ -type f -name "*.pdf" -exec grep -H 'Font' '{}' ';' How can I change this command such that it ...
0
votes
1answer
99 views

Finding out total PHP usage in MB's

I'm trying to find out total memory used by all PHP processes on my CentOS server. After some grepping and awking this is my final command. ps -e | grep php | awk '{print $1}' | xargs pmap | grep ...
0
votes
2answers
65 views

Grep first number value from quota -u

I would like to get first number from: [root@nowosci /]# quota -u testclient Ograniczenia dyskowe user testclient (uid 7798): System plików bloki miękki twardy pobł. pliki miękki twardy pobł. ...
0
votes
1answer
776 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 ...
1
vote
2answers
55 views

I want to filter out two lines from the output of a program [closed]

I have a command that outputs a bunch of data, but I only want two lines. Grep doesn't work because the lines I want are not next to one another. I can't seem to figure out sed... Help please. :) ...
1
vote
2answers
120 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
444 views

Testing if a server is up with curl and grep. Grep adds headings?

Hi I'm trying to see if a server I'm running has been stopped (if it has, it returns a 502 Bad Gateway message.) So I tried to do this : curl http://MY_URL | grep "502" The curl part returns what ...
0
votes
2answers
433 views

How to TAIL & EGREP for a specified time range in a BASH script

The subject mostly says it all. I am in charge of a few web servers running Ubuntu 12.04 running Apache2 & I would like to setup APC. Now I understand APC can hit segmentation fault issues when ...
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 ...
0
votes
1answer
324 views

find and delete files of a certain type inside a tar.gz file

Is there a way to not only find but also delete any .gz files inside a .tar.gz file? I found this link but I wouldn't know how to modify it to make it able to delete found files.
-3
votes
2answers
341 views

How can I count the number of lines matching a pattern returned from a linux command

How can I count the number of lines matching a pattern returned from a linux command I want the number of lines returned beginning with 'foo' , so if I pipe the output to grep will this ...
0
votes
1answer
280 views

grep to IP address when IP address in parameter

I need to grep to IP address ( as the following example ) , I use ksh script , # ifconfig -a | /usr/xpg4/bin/grep "100\.106\.2\.120 " inet 100.106.2.120 netmask ffffff00 broadcast ...
0
votes
1answer
228 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 ...
1
vote
4answers
303 views

greping multiple lines from MySql binlog

I have binlog from MySQL and I need to output certain time frame into a seperate file, how would I do that? here is sample of what binlog file contains: # at 460 #130120 0:09:17 server id 1 ...