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

learn more… | top users | synonyms

-2
votes
1answer
47 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
2k 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
154 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 ...
2
votes
5answers
452 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
131 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
452 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 ...
3
votes
9answers
2k 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
820 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
4k 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
245 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
862 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
242 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
557 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 ...
21
votes
4answers
4k 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
244 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
178 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
154 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.*$ ...
11
votes
5answers
1k 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. ...
5
votes
2answers
3k 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
268 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
136 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
934 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
108 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
1k 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 ...
1
vote
3answers
155 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 ...
21
votes
8answers
39k 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 ...
4
votes
4answers
2k 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
3k 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
349 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
803 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
301 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 ...
0
votes
4answers
620 views

how to find a text string which may be present in some unknown file in entire filesystem

I am stuck up with a problem I have a line 'something' in some file. In which file is this line that I have forgotten. In the entire root file system I would like to find out which file and where is ...
2
votes
5answers
723 views

Find files containing a string on the whole filesystem

I need to find all the instances of a given string in the whole filesystem, because I don't remember in which configuration files, script or any other programs I put it and I need to update that ...
1
vote
1answer
378 views

Need help on awk/sed/ perl pattern with regex / grep

Sample file output from grep file1:my $dbh = DBI->connect("dbi:mysql:$database_name", $DB_USER, $DB_PASSWD) file2:($dbc,$rc) = mysql_connect($mysql_host,$mysql_user,$mysql_password); The awk ...
4
votes
2answers
577 views

List top 404 URLs in Apache access_log

I'm looking for a command to list the 10 or 20 top 404 error URLs out of my apache access_log. Can anyone help me with this? thanks
1
vote
4answers
123 views

Locate a particular string in a directory

I want to do the following: cat *.xml | grep some_string_here This tells me if a particular string exists in an xml file in a directory. Unfortunately it does not tell me which file. how can I do ...
0
votes
2answers
256 views

How to strip logfile with grep to remove various dispensable information?

My logfile has the following format: Dec 26 13:11:48 192.168.1.1 kernel: ACCEPT IN=br0 OUT=vlan1 SRC=192.168.1.2 DST=74.125.43.147 LEN=44 TOS=0x00 PREC=0x00 TTL=63 ID=9312 DF PROTO=TCP SPT=11733 ...
1
vote
4answers
245 views

grep/list bash recursive

parts = grep "/root/backups/*" for part in $parts do echo $part rm -rf $part #delete done I basically need to iterate through a folder and return every item in the folder using a Bash ...
1
vote
3answers
1k views

tail -f and then exit on matching string

I am trying to configure a startup script which will startup tomcat, monitor the catalina.out for the string "Server startup", and then run another process. I have been trying various combinations of ...
2
votes
1answer
2k views

grep range of dates - apache log

I'm wondering how could I do the following greps: grep Apache log only for a range of dates, assume from 5/Nov/2010 to 5/Dec/2010 and grep Apache log starting from `15/Nov/2010 until the last ...
2
votes
4answers
2k views

grep multiple file types recursively

I am trying to figure out how to search for "_iterator_tag" string in all sub directories recursively and in files with extensions .cpp, .h, .hpp, .cxx, .inl for now all I can do is search each of ...
0
votes
2answers
188 views

Search multiple strings from multiple files

How to search multiple strings from multiple files with a single command. May be using grep or find or if there is any other in Linux or Solaris
0
votes
2answers
326 views

Getting data from log file

I'd like to get the memory usage from the following log entries. It's the number right after 200 for the URL. I'd like to get a list of highest memory usage first, like top 10. I think I'd use ...
4
votes
2answers
7k views

Getting the last match in a file using grep

What's the best way of getting only the final match of a regular expression in a file using grep? Also, is it possible to begin grepping from the end of the file instead of the beginning and stop ...
0
votes
2answers
96 views

Recover programmation source files

I've source code files (Java and C++) to recover from a broken RAID 1+0 array, I've been able to access the virtual drive with an other server but the ReiserFS partition can't be recovered with ...
0
votes
2answers
305 views

Passing a file with multiple patterns to grep

Let's say we have two files. match.txt: A file containing patterns to match: fed ghi tsr qpo data.txt: A file containing lines of text: abc fed ghi jkl mno pqr stu vwx zyx wvu tsr qpo Now, I ...
0
votes
1answer
293 views

Egrep Regular Expression to suppress certain lines

i try to use the following command to suppress certain lines of output that contain the strings "DST=192.168.1" or "DST=192.168.2" tail /var/log/messages | egrep -v -e ...
0
votes
1answer
127 views

How to display results without two first lines

When I run some bash command it returns 2 .. n lines of text (n is different each time, may contain blank lines). How to filter the output to display the result skipping lines 1 and 2? e.g. $ ...
1
vote
2answers
1k views

grep'ing through mailq

I want to filter some of the mail IDs returned by mailq (Postfix). However, the format is not very "grep-friendly", since the information for a single mail spans multiple lines: 9F701869D2 1356 ...