[BNM] Grep/egrep/fgrep/find/ help

Jason Bailey j.bailey at sussex.ac.uk
Tue May 26 13:01:04 BST 2009


Hi
Getting a bit confused. Im' trying to search for files that contain two 
strings (i.e. String1 AND string2). The strings are part of an sql query 
but may not be on the same line (easy I think if they're on the same line.

i.e. grep 'string1.*string2|string2.*string1' *.*  or something like that.

I'm trying to find where string1 might be part of the select or the where 
clause (so either way round).

What if the two strings are anywhere (not on the same line) in the file and 
either way round? Can anyone tell me a way to search for files containing 
both strings?

I was trying this from googling but not sure it's right....
grep dept_seq -e "`grep susx_group_mem *.*`" *.*

I was thinking of piping one grep output into the other but then I'd have 
to do it both ways to cover the strings being in any order. It would also 
be nice to have something which would extend to string3

Thanks
jason
-- 
Jason Bailey
IT Services
University of Sussex
http://www.sussex.ac.uk/USIS/phone/details.php?id=17011


More information about the BNMlist mailing list. Powered by Wessex Networks