Re: how to search files by pattern?
From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 05/29/04
- Next message: John W. Krahn: "Re: multiple space/tab"
- Previous message: Michael Tosch: "Re: Unix without shell"
- In reply to: dmitry_kulinich: "Re: how to search files by pattern?"
- Next in thread: Barry Margolin: "Re: how to search files by pattern?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 May 2004 00:09:18 GMT
On Fri, 28 May 2004 20:54:36 +0300, dmitry_kulinich <dkul@isd.dp.ua> wrote:
>
[ please bottom-post and trim your posts ]
>
>>find / -regex "<insert pattern here>" -type f > my_list_of_files_matching
> Great!...but if a pattern have 10 lines?
First of all, don't search your entire system. Only the directory trees that are
likely to have the file(s) you want. (not going to be in /proc or /dev or /lib,
right? Why search them?) My system locks up if I do grep -r 'search string' /
as root.
Find and grep -r both allow you to list the top directories of the trees you
want to search.
find /dir1 /dir2 /dir3...
grep -r 'search string' /dir1 /dir2 /dir3
One approach you could take would be to first locate the files that have ONE
of those lines:
(assuming bash and gnu grep)
$ grep -rl 'line 1............................................................\
...........' /dir1 /dir2 /dir3... > file1
This will give you a list of filenames that you can then feed to grep to look
for the next line (if you need to):
$ for file in $(cat file1); do ; \
grep -l 'line 2..........................................................\
.......' $file >> file2 ; done
And so forth....Though you can probably just use a short regular expression
to identify the lines. If you type them out literally, they will have to
be EXACT matches.
AC
-- Pass-List -----> Block-List ----> Challenge-Response The key to taking control of your mailbox. Design Parameters: http://tinyurl.com/2t5kp || http://tinyurl.com/3c3ag Challenge-Response links -- http://tinyurl.com/yrfjb
- Next message: John W. Krahn: "Re: multiple space/tab"
- Previous message: Michael Tosch: "Re: Unix without shell"
- In reply to: dmitry_kulinich: "Re: how to search files by pattern?"
- Next in thread: Barry Margolin: "Re: how to search files by pattern?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|