Hi,
I have to parse a very large file and I want to use the command grep (or any other tool).
I have to check in a log line the word "FAILED", print the line above and below.
For example:
id : 15
Satus : SUCESS
Message : no problem
id : 15
Satus : FAILED
Message : connection error
And I need to print only
id : 15
Satus : FAI...
I want to use grep to find all of the headers in a corpus, I want to find every thing up to the : and ignore every thing after that. Does anyone know how to do that? (Could I get a complete line of code)
...
I'm guessing it's not a Perl compatible regular expression, since there's a special kind of grep which is specifically PCRE. What's grep most similar to?
Are there any special quirks of grep that I need to know about? (I'm used to Perl and the preg functions in PHP)
...
There was a recent change on the server I do most of my work on and all PHP exec()'s now need absolute paths. Its faster than asking IT to ask it here.
So, does anyone know where grep is by default?
...
I am really used to doing grep -iIr on the Unix shell but I haven't been able to get a PowerShell equivalent yet.
Basically, the above command searches the target folders recursively and ignores binary files because of the "-I" option. This option is also equivalent to the --binary-files=without-match option, which says "treat binary f...
I am writing something that will allow users to search through a log of theirs. Currently I have this, where $in{'SEARCH'} is the string they are searching.
open(COMMAND, "grep \"$in{'SEARCH'}\" /home/$palace/palace/logs/$logfile | tail -n $NumLines |");
$f = <COMMAND>;
if ($f) {
print $Title;
print "<div id=log>\n";
...
To see all the php files that contain "abc" I can use this simple script:
find . -name "*php" -exec grep -l abc {} \;
I can omit the -l and i get extracted some part of the content instead of the filenames as results:
find . -name "*php" -exec grep abc {} \;
What I would like now is a version that does both at the same time, but on...
First of all, great praise goes out to PowerGREP it's a great program.
But it's not free.
Some of it's options I'm looking for:
Being able to use .NET regexp's (or similar) to find things in a filtered list of files through subdirectories.
Replacing that stuff with other regexps.
Being able to jump to that part of the file in some ...
I am writing a shell script to do a "tail" on a growing log file. This script accepts parameters to search for, and incrementally greps the output on them.
For example, if the script is invoked as follows:
logs.sh string1 string2
it should translate to:
tail -f logs.txt | grep string1 | grep string2
I am building the list of grep ...
This shell script is used to extract a line of data from $2 if it contains the pattern $line.
$line is constructed using the regular expression [A-Z0-9.-]+@[A-Z0-9.-]+ (a simple email match), form the lines in file $1.
#! /bin/sh
clear
for line in `cat "$1" | grep -i -o -E "[A-Z0-9.-]+@[A-Z0-9.-]+"`
do
echo `cat "$2" | grep -m 1 ...
I want to grep my server logs to collect all of the unique IP Addresses, and also to see all of the requests for a specific page. What is the best way to do this?
...
I just caught myself doing something I do a lot, and wanted to generalize it, express it, share it and see who else is following this general practice, to find some other example situations where it might be relevant.
The general practice is getting something wrong first, on purpose, to establish that everything else is right before und...
I have just read this interesting article about the implementation details for various languages that support regular expressions.
It describes an alternative implementation of regular expressions that uses non-deterministic finite automatons (NFAs) versus deterministic ones (DFAs). It claims that back-tracking DFA implementations (t...
What is the practical difference between the following two commands?
Command A
find . -type f -print0 | xargs -0 grep -r masi
Command B
find . -type f -print0 | xargs -0 grep masi
In short, what is the practical benefit of Command A?
...
This question is based on this answer.
Why do you get the same output from the both commands?
Command A
$sudo grep muel * /tmp
masi:muel
Command B
$sudo grep -H muel * /tmp
masi:muel
Rob's comment suggests me that ...
I have a simple grep command that returns lines that match from a file. Here's the problem: Sometimes, when a line matches, I want to include the line before it. What I want is a way to find all the lines that match a pattern, then use a different pattern to see if the line before each of those results match.
Let's say I want to get ...
This is what I have so far:
[my1@graf home]$ curl -# -o f1.flv 'http://osr.com/f1.flv' | grep -o '*[0-9]*'
####################################################################### 100.0%
I wish to use grep and only extract the percentage from that progress bar that CURL outputs.
I think my regex is not correct and I am also not sure ...
For instance, I have a large filesystem that is filling up faster than I expected. So I look for what's being added:
find /rapidly_shrinking_drive/ -type f -mtime -1 -ls | less
And I find, well, lots of stuff. Thousands of files of six-seven types. I can single out a type and count them:
find /rapidly_shrinking_drive/ -name "*offende...
I have a large collection of MSWord documents (approximately 40,000), which are the results of mailmerges (same main document, different data sources).
One of the merge fields is a text field which could have the text "Yes" or "No".
Is there an easy way to list which of the documents have that merge field set to the value "Yes"? (I'm...
I need to use chmod to change all files recursivly to 664. I would like to skip the folders.
I was thinking of doing something like this
ls -lR | grep ^-r | chmod 664
This doesn't work, I'm assuming because I can't pipe into chmod
Anyone know of an easy way to do this?
Thanks
...