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

learn more… | top users | synonyms

0
votes
1answer
2k views

How to find a file that contains the specified string in FreeBSD?

I'm searching for the way to find a file that contains specified string text. It should be fast as possible but its not that important. I was reading the manual, and I've build something like that: ...
1
vote
4answers
142 views

GREP show lines that contain this but not that

I would like to search for lines that contain "uploaded" but do not contain "09" Is there a way to do this with grep? (CentOS 5.6 if it matters).
5
votes
5answers
5k views

Grep progress bar using pv (pipe viewer)

I've got a huge directory on my computer and I need to search in every ruby file inside for a string. I could have done it like this : grep -R "string" *.rb but it takes really long and I'd like to ...
0
votes
3answers
559 views

tool to analyse/grep log files [closed]

Is there any web based GUIs to analyse or in realtime filter/grep log files from apache? log files that are access logs or error logs or postfix logs etc. Edit: I don't mean traffic analysis. Much ...
0
votes
1answer
927 views

Ubuntu command to constantly monitor a service?

I was curious if anyone new a command like tail or top to constantly monitor a service as it runs. I'm trying to watch sendmail currently to see who is connecting to it, but would like to have it a ...
0
votes
1answer
32 views

Compare/Calculate like files

I have program generating reports on a regular basis. These reports are follow a simple and consistent format (specifically, these are "OProfile profiling reports). Each line's format is: ...
0
votes
3answers
484 views

grep out unique senders from a huge list of emails

I just found a huge list of emails under my user account in Centos /home/user/mail/new I opened some of them and noticed they were sent from a particular cron job. From address is root@hostname.com. ...
0
votes
2answers
716 views

How to update my grep utility on CentOS 5.6?

I'm using a CentOS 5.6 system. Since there is a bug in my version of grep. I want to upgrade to a new version. I tried to use yum to update(upgrade) it, but failed. [root@localhost ~]# cat ...
1
vote
2answers
5k views

How to grep httpd error_log within a time range?

How can I grep only lines from a huge (120GB) httpd error_log based on a time range, say: from 2011-11-15 11:30 pm to 2011-11-16 01:30 am Thanks!
4
votes
4answers
184 views

Possible to use grep simply for finding files in a directory structure?

I like using grep but sometimes I just want to search for the names of files in a directory tree, but don't want grep to open the files and search inside them. Can grep do this?
38
votes
5answers
50k views

How do I grep through binary files that look like text?

I have binary files that should be text (they're exported logs), but I can't open it with less (it looks ugly - it looks like a binary file). I found that I could open it with vi and I can cat it ...
1
vote
5answers
349 views

Extracting lines from a file based on prefix

I need to extract all lines from file2 that begin with an id # prefix contained in file1. File 1 is single column like: 324 399 408 135236 321590 File 2 is multi-column like: 1 [tab] 108 [tab] ...
6
votes
3answers
234 views

OS/2 grep had a great feature where it would show you n lines BEFORE the search item was found. Is there an equivalent in unix anywhere?

Solaris would be preferable, but I'll take linux or something I can compile. Does such a beast exist?
1
vote
3answers
3k views

How do I search by multiple keywords when using awk or grep?

I have a collection of files. I want to search through them all with grep to find all and only those which contain anywhere within them both the strings keyword1 and keyword2. I would also like to ...
0
votes
2answers
104 views

Display specific word in file. To be used as varible, grep for email in log

I'm looking to display just the email address in the /var/log/secure file. The email goes into a variable, so just grepping for lines won't work. I know how to string together sed commands, but is ...
3
votes
2answers
604 views

egrep matching group not printing?

I'm trying to create a bash script that will grep lines from a file using egrep. I've created the regex that should group the information I want, the issue is trying to get the output. I've been ...
16
votes
7answers
2k views

Can awk be used instead?

I would like to get the number from rating as output from this # nc localhost 9571 language: language:en_ZA.UTF-8 language:en_ZW.UTF-8 session-with-name:Ubuntu Classic (No effects):gnome-session ...
2
votes
3answers
2k views

grep - recognize carriage return as new line

I want to search a webserver running unix for php-files containing a specific string. Usually I use these commands to accomplish this: find . -name "*.php" -print0 | xargs -0 grep -H -i "the string ...
-2
votes
1answer
52 views

matching any part of a expression using grep

How Can I use grep so as to return me all matches for not only entire expression but also any part of the expression. example: grep "foobar" foo where foo contains text foo should give me a match ...
4
votes
3answers
4k views

grep or sed to find a integer value above a given amount?

This is in reference to another question: How do I use robocopy to list all files over a certain size recursively? I would like to parse output of a command (or cat a log file) and find a string ...
2
votes
1answer
168 views

compare first or third position

The mysql general log file looks like this... 110822 14:41:14 103700 Query SHOW FULL TABLES FROM `engine` LIKE 'PROBABLYNOT' 103700 Query SHOW FULL TABLES FROM `engine` LIKE ...
3
votes
5answers
2k views

How to remove a certain symbol for a bash script

I have a bash script where I get the disk usage, for example 60%. How can I remove the % symbol? Using grep or awk?
1
vote
3answers
158 views

Saving the out of tail

The following does not work... tail -f /var/log/mysql/general.log | grep Connect > /home/myfile.txt If I remove the "-f" switch then I am able to save the output to a text file, but it does not ...
0
votes
2answers
2k views

tee and grep at the same time (shell)?

I'm trying to run a server that writes to $log (a txt file) and then find all the text in the logfile that starts with [1] and put it in another file. Here's my attempt. tee -a $log works along with ...
2
votes
2answers
465 views

Locate a string in a folder and the file it came from?

I am trying to find some keywords in my /var/log directory, so using cd /var/log cat * | grep keyword I find the string is in that directory and see the lines it exists on, but don't know which ...
4
votes
9answers
4k views

grep to display folders which contain files which contain a string

I need to run a grep on my server to search for files which extend a CodeIgniter 1 file, as we are upgrading to CI2. In one folder contains several hundred site-specific folders like such: ...
0
votes
3answers
1k views

AWK - Is it possible to search for pattern, then sort results based on a wildcard?

I am storing a number of individually serialized PHP arrays to a file. Each line of the file contains one serialized array. For example: a:2:{s:4:"name";s:8:"John Doe";s:3:"age";s:2:"20";} ...
6
votes
2answers
6k views

cat * | grep something… what file is the result in?

If one was to run the following command cat * | grep DATABASE the shell would spit out all the lines in * files that contained the word DATABASE in them. Is there any way to also spit out what file ...
1
vote
2answers
513 views

find files and search for within tail

The following is working as expected. find /opt/ -name "somefile.out" -exec grep 'Connection refused' {} \; | more But if I want to search only in the tail of the found files, I can not add tail or ...
2
votes
5answers
1k views

remove 2 lines from output, grep match regular expression plus next 1

i have a log file from postgresql that has log entries of the format; LOG: execute <unnamed>: /match this here/ DETAIL: parameters: /also want to filter this line/ I thought it might be ...
1
vote
1answer
282 views

Using Find, Grep, Awk, or Sed To Rename Server After Cloning

My client tells me they have cloned a VM in VMWare of an Ubuntu Linux server. Now it's my job to get into all the files and find out what still has the old server name of "bishop" and change it to ...
1
vote
1answer
696 views

redirecting “tail --follow=name | grep” to a file

Here is my scenario: I have a log file that is being wrote too by an application. The log file is named "alarms.log". I want to tail the file for a certain string and redirect that to a file called ...
24
votes
4answers
7k views

In tail -f, how do I filter out stuff that has certain keywords?

I want to tail -f my logs. However, I want to filter out everything that has the words: "ELB", "Pingdom", "Health"
0
votes
1answer
378 views

Following a file mixed with grep to exclude lines

Basically I want to combine the function whereby you can Less a file and then Shift+F to follow the file, as you would do with Apache's access.log. However I would like the output to ignore/hide ...
0
votes
2answers
189 views

grep -r pattern ./ without recursion?

I want to run the grep -r pattern ./ but WITHOUT recursively going through the sub directories. When I removed the -r flag, I didn't get any output in my terminal. What flag am I supposed to use to ...
2
votes
1answer
188 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.*$ ...
13
votes
5answers
3k views

Grepping through .gz log files

Does there exist a magical shell piping which would allow easily to grep through bunch of .gz log files without needing to extract them somewhere? .gz files are Apache logs, result of log rotation. ...
8
votes
3answers
6k views

How can I handle spaces in file names when using xargs on find results?

One of my common practices is to perform greps on all files of a certain type, e.g., find all the HTML files that have the word "rumpus" in them. To do it, I use find /path/to -name "*.html" | xargs ...
1
vote
0answers
410 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 ...
1
vote
2answers
139 views

Need help with grep urgently to comply with subpoena request

I am not a system administrator but I run a little website and today I have received a subpoena request from police, in order to comply I need to extract IP addresses from our server logs for needed ...
0
votes
2answers
2k views

Is there a flag I can pass to either `df` or `mount` to make them display results for only locally-mounted filesystems?

I'm getting mighty tired of having to manually egrep out NFS- and SMB-mounted filesystems whenever I am checking on the condition of locally-mounted filesystems. So, my question is thus: is there some ...
1
vote
2answers
114 views

ignore lines grep

I have a very annoying message being output from a process I'm running. I'd rather not remove the line, but simply remove it with grep The messages to ignore all contain the word "requests". I could ...
1
vote
4answers
2k views

How I can tell grep to search in file that I have permission?

When I call cd / grep -r "some_str" . then I see lots of files printed on the screen and in the end of the line I see ": Permission denied". How I can tell the bash to search only in file that I ...
2
votes
3answers
166 views

alias to replace a text in file

here is a practical situation.I facing some of my files where there is a common string in these files.I usually will open vi and do some thing like :%s/text/replacement/g and I have to do it in ...
24
votes
8answers
58k views

how to find out mac addresses of all machines on network

Is there some easy way to find out mac address of all machines on my network rather than doing an SSH into each and ifconfig | grep HWaddr if there are 300 machines on network I really need some easy ...
5
votes
4answers
3k views

Combine multiple unix commands into one output

I need to search our mail logs for a specific e-mail address. We keep a current file named maillog as well as a week's worth of .bz2 files in the same folder. Currently, I'm running the following ...
7
votes
9answers
5k views

How to grep the IP address from ifconfig output

Following is my ifconfig output eth0 Link encap:Ethernet UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX ...
0
votes
1answer
389 views

Move all images in folder to subfolder, and update all references to those images to their new location?

I have a folder which contains a ~50 text files (PHP) and hundreds of images. I would like to move all the images to a subfolder, and update the PHP files so any reference to those images point to the ...
2
votes
4answers
956 views

Is there a simple command-line HTTP proxy that outputs to STDOUT?

Is there a command-line HTTP proxy that outputs to STDOUT so I can use it with Unix pipes? I want to do something like this: Start the proxy at the command-line: $ proxy -p 8888 | grep "Text I'm ...
1
vote
2answers
415 views

finding a group of string common in two files

I have used diff command in past.I faced a situation to which I did not had a clue here are some text strings (which can be stored in a file) CONFIG_XEN=y CONFIG_XEN_PVHVM=y ...