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
9
votes
2 answers

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

I'm getting mighty tired of having to manually egrep out NFS- and SMB-mounted file systems whenever I am checking on the condition of locally-mounted file systems. Is there some combination of flags that I can pass to either df or mount that will…
ZaMoose
  • 299
  • 1
  • 3
  • 9
9
votes
5 answers

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 commands to search for the file: grep…
Ben McCormack
  • 705
  • 4
  • 9
  • 16
9
votes
4 answers

Searching for literal "> \" using ack-grep

I am looking for lines that literally have a greater than character (a ">") followed by a space followed by a backslash character (a "\") i.e., a line with this: > \ I thought escaping would allow this, and for the greater-than it does: $…
Stephen Gornick
  • 261
  • 2
  • 5
8
votes
5 answers

Calculate sum of several sizes of files in Bash

I have list of files in a file, cache_temp. In file…
Piduna
  • 541
  • 4
  • 12
  • 25
8
votes
5 answers

Grep-ing gzipped files

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 files, one by one, grep them and delete the unzipped…
Julien Genestoux
  • 609
  • 8
  • 19
8
votes
2 answers

Cron job checking for changes in Git repository

We have just moved our server configs to a Git repository. Therefore there should not be any changes in any of the repository folders. I was thinking about how I could set up a cron job to check for any uncommited changes. How could a cron job be…
HNygard
  • 183
  • 1
  • 7
8
votes
6 answers

Can I run grep against a zOS dataset via Unix system services?

I have a search I'd like to run against a zOS dataset, and I know how to form the grep command. I have access to the machine via Unix system services, how to I address a dataset from that environment?
C. Ross
  • 3,075
  • 9
  • 35
  • 36
8
votes
5 answers

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?
pmerino
  • 461
  • 2
  • 5
  • 11
8
votes
8 answers

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…
AlienWebguy
  • 91
  • 1
  • 1
  • 8
8
votes
2 answers

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 each line is apart of? I tried to use the -H…
Jake Wilson
  • 8,814
  • 29
  • 97
  • 125
8
votes
9 answers

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 packets:0 errors:0 dropped:0 overruns:0 carrier:0 …
Registered User
  • 1,463
  • 5
  • 18
  • 37
8
votes
2 answers

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
tykho
  • 81
  • 1
  • 2
8
votes
2 answers

grep to find files that contain a string greater than x characters long?

Is it possible to locate files in a directory that have strings (with no spaces) longer than x length?
sbuck
  • 391
  • 2
  • 6
  • 16
7
votes
1 answer

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, which is expected: tail -F server.log | grep…
Dale Mahalko
  • 755
  • 1
  • 6
  • 17
7
votes
4 answers

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 value, convert it to an integer and then see if that…
brandeded
  • 1,845
  • 8
  • 32
  • 50
1 2
3
21 22