Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!lotus!campbell From: campbell@lotus.com (Jim Campbell) Newsgroups: comp.unix.questions Subject: Re: Attn: AWK GURUS (Generic Search) Message-ID: <1991Mar8.162348.7463@lotus.com> Date: 8 Mar 91 16:23:48 GMT References: <354@marst2> <1991Feb28.044421.23405@athena.mit.edu> Sender: news@lotus.com Reply-To: campbell@acadia.UUCP (Jim Campbell) Organization: Lotus Development Corp. Lines: 51 Hi, I am posting this response to the net because "marst2" is unknown any way I try it ...... In article <354@marst2> you write: >I want to do a quick generic search of a rather large data base and I want >to do the search based on certain record cols. If I have records that look >like this: > >abc defghi j klmnop qrst uvw x y z >a bc defg hij lmnop qrst uvw x yz >ab c defg hi j klmn op qrst u vwxyz > >And say I want to find only the records with (a) in col1, (nop) in col19-21, >(v) in col29 and (y) in col34. > >I want to do this in a script where the record cols and params are left to >to the users choice. > >I tried doing this with: > >-- >-- >while true >do > a=`line do cuts of $a and compare to given params..... > You don't need awk, or any Scuds, to do this.... Try this: grep '^a.\{17\}nop.\{7\}v.\{4\}y' Note that none of the lines you gave fall into the column specfications you gave. I modified the second line by removing one of the spaces preceding the "u", and which made the second line conform to your specification, and this grep command matched that line. Here is my input file: 1234567890123456789012345678901234567 abc defghi j klmnop qrst uvw x y z a bc defg hij lmnop qrst uvw x yz ab c defg hi j klmn op qrst u vwxyz Bonne chance! -- Jim Campbell, Lotus Development Corporation | harvard!ima \ 1 Rogers St., Cambridge, MA 02142 | >!lotus!campbell 617/693-5652 | uunet /