Attn: AWK GURUS (Generic Search)
Jim Campbell
campbell at lotus.com
Sat Mar 9 02:23:48 AEST 1991
Hi,
I am posting this response to the net because "marst2" is unknown
any way I try it ......
In article <354 at 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 <file` || break
> 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' <file>
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 /
More information about the Comp.unix.questions
mailing list