The grep tag has no wiki summary.
2
votes
2answers
49 views
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?
1
vote
2answers
28 views
Odd error with regular expression in grep
I'm running the following command:
cat something | egrep "(abc|def)$"
On a server running Linux.
The same OS with kernel 2.6.18 gives the correct answer, while with 2.6.19 I get:
Illegal variable ...
1
vote
1answer
23 views
How to grep string in perl [closed]
How to grep the string in perl.
Variable sessionWeb contains a web page html code. I want to grep "active Sessions" from this and want to print as below. For example the line in the web page will be
...
0
votes
1answer
28 views
Grep to find lines starting at pattern A until pattern B is matched
I have a log that contains bits like this:
[2012-04-16 15:16:43,827: DEBUG/PoolWorker-2] {'feed': {}, 'bozo': 1, 'bozo_exception': URLError(error(110, 'Connection timed out'),), 'entries': []}
...
0
votes
2answers
57 views
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 ...
2
votes
4answers
114 views
bash : “set -e” and check if a user exists make script exit
I am writing a script to install a program with bash, I want to exit on error so I added "set -e" in the beginning of my script.
The problem is that I have to check if a user exists inside of my ...
1
vote
2answers
55 views
Grepping through the results of apachectl -S
I have a server with about 300 virtual hosts. When I want to make sure a specific httpd.conf file is loaded into the Virual Host config and the syntax is correct, I run apachectl -S. The problem is, ...
1
vote
1answer
49 views
Regular expressions in GREP
I have an .xml file. The tags inside are:
<Info>Product</Info>
Now, I have 20 000 tags like this in the file. One tag however, starts properly but it is missing a proper closing tag. ...
15
votes
4answers
562 views
How to prevent “ps” reporting its own process?
$ ps | grep django
28006 ttys004 0:01.12 /usr/bin/python bin/django celeryd --beat
51393 ttys005 0:01.45 /usr/bin/python bin/django celeryd -l INFO
51472 ttys005 0:01.29 /usr/bin/python ...
1
vote
1answer
50 views
Ack search for literal strings
I am sick of having to escape things when I want to search for part of an html tag.
How can I ack search for exactly what I type without having to escape stuff?
e.g.
ack-grep 'console.log(foo'
I ...
2
votes
3answers
76 views
How do I make grep results colored?
I have some output of my program:
# php check.php | grep -E "rule_1|rule_4"
I would like results equaling to rule_1 to be red and results equaling to rule_4 to be blue.
Is this possible, because at ...
0
votes
4answers
139 views
solaris + grep syntax in solaris
my target is to match Exactly the string snmpmanager from hosts file on solaris & linux
the following command work on Linux (red-hat 5.1) but not for SunOS , please advice how to fit the syntax ...
4
votes
2answers
79 views
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 ...
2
votes
2answers
66 views
egrep not working in crontab
I have a simple bash script wich works fine when running in command line, but not in crontab:
#!/bin/bash
PATH=/usr/bin:/bin
for f in /data/home/cwolff/tmp/*access_log*.txt;
do
egrep "r:[A-Z]+ ...
0
votes
4answers
154 views
grep and tabs: no match
#cat sample
1 -1 2
2 2 2
2 1-1 3
I need to get all the lines that contains negative value, that is 1st line only. Values are tab-separated.
First I tried
# grep "\-1" sample
1 -1 2
2 ...
0
votes
1answer
79 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
103 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).
3
votes
4answers
279 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 ...
-1
votes
2answers
87 views
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 ...
0
votes
1answer
97 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
26 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
83 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
65 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
1answer
478 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
85 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?
3
votes
3answers
248 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
107 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
213 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
165 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
46 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
165 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 ...
17
votes
7answers
826 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
357 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
43 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
223 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
76 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
89 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
80 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
252 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
80 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
8answers
561 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
267 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";}
...
5
votes
2answers
402 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
47 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
4answers
194 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
120 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
155 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 ...
16
votes
4answers
968 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
67 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
122 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 ...