I have a script that I'm running from the home directory to search for all files called "script.sh" that contain the string "watermelon". It's not finding anything but I can clearly see these scripts in the subdirectories. Could someone please suggest a change to the command I'm using:
find . -name script.sh | grep watermelon
...
I'm trying to filter webserver log files using grep. I need to output all lines containing 65.55. but exclude those matching lines which contain msnbot.
My starting point is this - but it doesn't work:
grep "^.*65\.55\..*(!msnbot).*$" ex100101.log > results.txt
I'm using grep for Windows (hence double quotes) but I doubt this matter...
I've got a data structure that is a hash that contains an array of hashes. I'd like to reach in there and pull out the first hash that matches a value I'm looking for. I tried this:
my $result = shift grep {$_->{name} eq 'foo'} @{$hash_ref->{list}};
But that gives me this error: Type of arg 1 to shift must be array (not grep itera...
I have a file called "physics 1b.sh".
In bash, if i try
x="physics 1b"
grep "string" "$x".sh
grep complains:
grep: physics 1b: No such file or directory.
However, when I do
grep "string" physics\ 1b.sh
It works fine. So I guess the problem is something to do with the variable not being expanded to include the backslash that gr...
I want to recursively search through a directory of text files and replace every occurrence of foo within the files with bar. What is the easiest way to accomplish this?
I imagine that grep would do the job in one line, but I can't seem to find an example of this.
I'm working in OS X.
...
I have something to do that must be finished before 4.00PM.
I want to create a batch file with awk, grep or sed that keeps all lines beginning with 'INSERT' and deletes the other lines.
After this, I want to replace a string "change)" by "servicechange)" when the 3rd word in the treated line is "donextsit".
Please explain how to d...
I'm using regex to match all non-quoted property names in my json files. Eclipse has no problem finding the desired matches, but when I want to replace the matched strings with "$2", I get this error: Match string has changed in file filename.json. Match skipped
Here's the regex I'm using:
((\w+)\s*(?!['"])(?=:))
Any idea on how to w...
Hi, I'm having trouble with grep.. Which four patterns should I use with PHP's preg_grep to extract all instances the "____" stuff in the strings below?
1. <h2><a ....>_____</a></h2>
2. <cite><a href="_____" .... >...</a></cite>
3. <cite><a .... >________</a></cite>
4. <span>_________</span>
The dots denote some arbitrary characters ...
I'd like to use ngrep and/or perl to monitor the incoming data stream on a socket, then, when the appropriate characters arrive, like in this case, the string "192.168.1.101:8080", input to the data stream a redirect to another ipaddress, such as "192.168.1.102"
Is this even possible?
...
I have a data file that looks like the following example. I've added '%' in lieu of \t, the tab control character.
1234:56% Alice Worthington
alicew% Jan 1, 2010 10:20:30 AM% Closed% Development
Digg:
Reddit:
Update%% file-one.txt% 1.1% c:/foo/bar/quux
Add%% file-two.txt% 2.5.2% c:/foo/bar/quux
Remove%% file-thre...
I need a way to quickly search a large number of Crystal reports (with sub-reports) for the names of several stored procedures. (Trying to find dependencies.) I'm running Windows XP and downloaded this grep program. So far, I'm not convinced that it's working. Does anyone know of a reliable way, other than opening each report and sub-rep...
I end up typing
grep -Rni pattern .
and awful lot. How do I make this into an alias like
alias gr='grep -Rni $@ .'
Running that gives:
$ gr pattern
grep: pattern: No such file or directory
Even though the alias looks fine:
$ type gr
gr is aliased to `grep -R $@ .'
It seems that the $@ and the . get swapped when it's actually ...
I don't understand the last line of this function from Programming Perl 3e.
Here's how you might write a function that does a kind of set intersection by returning a list of keys occurring in all the hashes passed to it:
@common = inter( \%foo, \%bar, \%joe );
sub inter {
my %seen;
for my $href (@_) {
while (my $k = eac...
Hello everyone:
I am trying to analyze my agent results from a collection of 20 txt files here.
If you wonder about the background info, please go see my page, what I am doing here is just one step.
Basically I would like to take only my agent's result out of the messy context, so I've got this command for a single file:
cat run15.tx...
I've got a problem where calling grep from inside java gives incorrect results, as compared to the results from calling grep on the same file in the shell.
My grep command (called both in Java and in bash. I escaped the slash in Java accordingly):
/bin/grep -vP --regexp='^[0-9]+\t.*' /usr/local/apache-tomcat-6.0.18/work/Catalina/localh...
I want to get automatically to the positions of the results in Vim after grepping, on command line. Is there such feature?
Files to open in Vim on the lines given by grep:
% grep --colour -n checkWordInFile *
SearchToUser.java:170: public boolean checkWordInFile(String word, File file) {
SearchToUser.java~:17: public boolean checkWor...
I have a perl script (or any executable) E which will take a file foo.xml and write a file foo.txt. I use a Beowulf cluster to run E for a large number of XML files, but I'd like to write a simple job server script in shell (bash) which doesn't overwrite existing txt files.
I'm currently doing something like
#!/bin/sh
PATTERN="[A-Z]...
[Update2] As it often happens, the scope of the task expanded quite a bit as a understood it better. The obsolete parts are crossed out, and you find the updated explanation below. [/Update2]
I have a pair of rather large log files with very similar content, except that some strings are different between the two. A couple of examples:
...
I want to find files that have "abc" AND "efg" in that order, and those two strings are on different lines in that file. Eg: a file with content:
blah blah..
blah blah..
blah abc blah
blah blah..
blah blah..
blah blah..
blah efg blah blah
blah blah..
blah blah..
Should be matched.
...
When searching code for strings, I constantly run into the problem that I get meaningless, context-less results. For example, if a function call is split across 3 lines, and I search for the name of a parameter, I get the parameter on a line by itself and not the name of the function.
For example, in a file containing
...
someFuncti...