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

learn more… | top users | synonyms

-1
votes
0answers
28 views

nmap OS detect parsing to list [closed]

Sorry for my bad English, I'm from Russia. I want parsing IP from list where open 23 port and out in new file list ip where have OS Windows IP list mast to be so: 192.168.0.1 192.168.0.2 192.168.0.3 ...
0
votes
2answers
59 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
44 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
41 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
32 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
37 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
66 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
84 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
276 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
151 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
31 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 ...
0
votes
1answer
170 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
49 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
68 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
95 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
397 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
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
40 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
897 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
156 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
56 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
259 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
310 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
57 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
344 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
131 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
123 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
294 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
453 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
74 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
60 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
448 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
48 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
108 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
237 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
366 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
58 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
107 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
179 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
220 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
2answers
182 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
231 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 ...
0
votes
2answers
329 views

remove non-printing characters

I have a tab delimited text file. When I open the file with vi editor, I can see ^M character (in blue color). This is not part of my data. It got there because the original SQL data had carriage ...
0
votes
1answer
129 views

grep + match value only if value in the end of line

please advice what is wrong with my code, ( I run this code on both OS linux and solaris ) I don't get the line from: "file ended with .tmp" example: I need to verify if $FILE ended with .tmp ...
3
votes
2answers
717 views

Is there a way to find a specific word in all files/folders in Linux?

I usually use grep word * while being in a folder which includes files that have that word. But in this folder i also have folders which under them there are files that have that word, what is the ...
0
votes
3answers
192 views

grep + Regular Expressions to match uniq number

My target is to verify if $FILE is a backup file ( backup file ended with xxxx.xx.xx.xx number Example of backup files ls /etc/VRTSvcs/conf/config main.cf.17Dec2012.09.10.14 ...
-4
votes
3answers
67 views

grep only returns help text [closed]

Well, I am perplexed. I am working with an Ubuntu server and I type in grep 'bash' *.sh BUT fgrep 'bash' *.sh works like a champ. which grep and which fgrep both point to their respective ...
0
votes
0answers
183 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` ...
2
votes
1answer
98 views

finding files that match a precise size: a multiple of 4096 bytes

I have several drupal sites running on my local machine with WAMP installed (apache 2.2.17, php 5.3.4, and mysql 5.1.53). Whenever I try to visit the administrative page, the php process seems to ...