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

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ł. /dev/root 100256 51200000 51200000 …
Spacedust
  • 568
  • 5
  • 13
  • 28
0
votes
2 answers

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 I expect it to. But when I pipe it into grep, grep…
interstar
  • 1,281
  • 4
  • 18
  • 23
0
votes
2 answers

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 acting on PHP code that has errors or quirks. So…
0
votes
2 answers

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 only need lines that contain mtype of 164 and for…
Poul
  • 101
  • 1
0
votes
1 answer

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 100.106.2.255 but how to grep IP address from parameter…
yael
  • 2,433
  • 5
  • 31
  • 43
0
votes
1 answer

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 'Contact' and 'User-Agent' however these could be…
Luke B
  • 101
  • 1
0
votes
2 answers

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 return /r sign. 713498 29195 NWSO NE SA COLLEGE…
shantanuo
  • 3,579
  • 8
  • 49
  • 66
0
votes
1 answer

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 or .old etc ... code with the following example set…
yael
  • 2,433
  • 5
  • 31
  • 43
0
votes
3 answers

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 main.cf.17Dec2012.09.10.23 main.cf.17Dec2012.09.10.31 Example of…
yael
  • 2,433
  • 5
  • 31
  • 43
0
votes
1 answer

Grep /var/log for hacker/script kiddy activity and e-mail?

CentOS 6 Apache Server version: Apache/2.2.15 (Unix) Thinking about how to automatically, once a day, grep all the logs in /var/log/httpd for hacker, phishing, etc activity and e-mail it to myself so I can evaluate what I might need to do. But what…
Jason
  • 11
  • 2
0
votes
3 answers

How can I grep for two values from the same input being piped to it?

CentOS 5.x I'm trying to build a shell script that searches data provided via stdin. Here's an example of the input stream: Date: 1/1/11 Time: 12:00 AM Foo: 12345 Foo1: dskjflsdkjflksdjlfds Foo2: 123456789 Foo3:…
Mike B
  • 11,871
  • 42
  • 107
  • 168
0
votes
1 answer

puppet master --compile logs errors to stdout

I see a bug about this that was accepted and then closed a year ago: http://projects.puppetlabs.com/issues/3670 but I'm using puppet 2.7.14 and am getting the same issue. I'm trying to use "puppet solo" (i.e. just running puppet apply on each…
danny
  • 123
  • 6
0
votes
2 answers

Find text, then insert linebreak and some php code across multiple files

I have a certain php code comment that appears in about 75 files across several users. This command succsessfully locates it. (I didn't bother looking for the double slashes because I wasn't sure about escaping them and they really don't matter for…
TecBrat
  • 183
  • 12
0
votes
3 answers

tool to analyse/grep log files

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 more about greping error logs to locate some error…
thevikas
  • 153
  • 1
  • 8
0
votes
1 answer

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: Unique_name,number I wish to run over all the reports I…
Trevor
  • 193
  • 1
  • 4