0
votes
1answer
33 views

Is there a tool for indexing a directory in order to perform cheap content search? (hashing by word, for example)

I am often using grep -R on an entire directory tree to find all files that contains a specified word. I wonder if there is a tool that makes the whole operation much faster, maybe via hashing? (Unix ...
0
votes
1answer
71 views

find and delete files of a certain type inside a tar.gz file

Is there a way to not only find but also delete any .gz files inside a .tar.gz file? I found this link but I wouldn't know how to modify it to make it able to delete found files.
4
votes
3answers
309 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?
6
votes
3answers
228 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?
20
votes
4answers
3k 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"
4
votes
4answers
2k views

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 ...
1
vote
4answers
122 views

Locate a particular string in a directory

I want to do the following: cat *.xml | grep some_string_here This tells me if a particular string exists in an xml file in a directory. Unfortunately it does not tell me which file. how can I do ...
2
votes
2answers
6k views

Getting the last match in a file using grep

What's the best way of getting only the final match of a regular expression in a file using grep? Also, is it possible to begin grepping from the end of the file instead of the beginning and stop ...
0
votes
1answer
2k views

Grep date with regex

I have files with lines in the following formats: . . . 12/16/09 17:56:30.211 rest of line... . . . 12/17/09 05:34:10.809 rest of line... . . How do I grep the lines out of this file that are ...
2
votes
2answers
2k views

How do I make (non-gnu-)grep ignore binary files?

Hey, I am on a HP-UX server here. When recursively grepping a directory tree, I have problems when the tree also contains binary files: grep treats them as text files and displays very long lines ...
10
votes
2answers
6k views

When to use single-quote, double-quote in grep?

While trying to search for a simple pattern "hello" in a file, all the following forms of grep work: grep hello file1 grep 'hello' file1 grep "hello" file1 Is there a specific case where one of ...