Questions tagged [grep]

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

The grep utility searches a pattern (regular expression) in a text file. There are many options to control how matches are performed and how to display matches.

External references

Tutorials

Further reading

See also grep on Unix & Linux Stack Exchange for more detailed reading.

326 questions
4
votes
3 answers

How do I programmatically convert putty logs to human-readable, searchable files?

Background: I have a Windows 7 workstation and use PuTTY for SSH connectivity to Linux servers with session logging enabled. I previously used the Printable output option but that has the benefit of no escape characters but the drawback of making…
4
votes
2 answers

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 to use grep and cut to output the unknown…
uxphreak
  • 43
  • 1
  • 3
4
votes
4 answers

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 following require ["fileinto", "variables",…
Jan
  • 276
  • 1
  • 3
  • 6
4
votes
2 answers

Local full text index for a directory tree, a quicker alternative for grep -R

I have a large directory tree of source files. I want to search around all these files. My first instinct is to use grep -R or ack, but either way they just sequentially read all the files. Is there some lightweight programme that I can install that…
Amandasaurus
  • 31,471
  • 65
  • 192
  • 253
4
votes
3 answers

Is there a way to grep with a constrained file type?

right now i am using something like this: find . -name "*.xml" | xargs grep -l "foobar" it works, but i was wondering if grep has this functionality built in?
numan
  • 143
  • 2
4
votes
1 answer

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 little more dynamic than just repeatedly typing ps…
ehime
  • 597
  • 2
  • 7
  • 15
4
votes
2 answers

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!
ohho
  • 1,005
  • 8
  • 19
  • 34
4
votes
4 answers

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?
SlyMcFly
  • 279
  • 1
  • 2
  • 7
4
votes
6 answers

"watching" a log on FreeBSD vs Linux

On Linux systems I can watch -n1 tail /var/log/whatever.log or watch -n1 grep somestuff /var/log/whatever.log To show updates to a log every 1 seconds. On FreeBSD however, the watch command does something else entirely. Who knows a good FreeBSD…
Cory J
  • 1,568
  • 5
  • 19
  • 28
3
votes
2 answers

Ansible yum update then email me the results

Writing a playbook to perform yum updates and then get an email from each server. I'd like the email to contain the changed contents of yum.log. IOW, I want the results of: grep [today's date] /var/log/yum.log to be emailed from each server. I…
Mike
  • 53
  • 1
  • 6
3
votes
3 answers

Cron: only send mail if output contains string

Can I make cause cron to only send the email if the output (stderr) contains a certain string? I'm aware of this answer but the command I run doesn't distinguish between stdout/stderr, it always just outputs to stdout, so I need to look for a…
TheStoryCoder
  • 254
  • 3
  • 13
3
votes
1 answer

Escaping special characters in grep regex

I am trying to run a grep regular expression on a file, where I have to exclude lines where "00" and "0" appear. I came up with this expression: grep -a -E \"stored\"\:\ \"\*123\*(?!00)[0-9]{2,5}\#\" $filename But when I try to run it in bash, I…
Unpossible
  • 249
  • 1
  • 7
  • 20
3
votes
3 answers

Grep regex Stdout to telnet

I'm trying to use grep to get a regex result and pipe the results on-the-fly to telnet running an open port to a node server. The grep received continuous, but varied in interval, commands from a program running, greps out a number then pipes that…
kirgy
  • 179
  • 11
3
votes
2 answers

how to get the desired value in bash shell from the lshw output?

I want to extract the info from lshw output where it says: -cpu product: ...... I want only the product info of this -cpu. How can I do that with awk or sed?
UnixUser
  • 43
  • 2
3
votes
3 answers

ps ax | grep java with no wrapping in the terminal?

Is there a way to execute ps ax | grep java without it wrapping on the terminal?
Noah Campbell
  • 619
  • 2
  • 9
  • 15