grep replacement

Russ Rew russ at groucho.ucar.edu
Mon May 30 07:45:49 AEST 1988


I also recently had a need for printing multi-line "records" in which a
specified pattern appeared somewhere in the record.  The following
short csh script uses the awk capability to treat whole lines as fields
and empty lines as record separators to print all the records from
standard input that contain a line matching a regular specified as an
argument:

#!/bin/csh -f
awk 'BEGIN {RS = ""; FS = "\n"; OFS = "\n"; ORS = "\n\n"} /'"$1"'/ {print} '


     Russ Rew * UCAR (University Corp. for Atmospheric Research)
	 PO Box 3000 * Boulder, CO  80307-3000 * 303-497-8845
	     russ at unidata.ucar.edu * ...!hao!unidata!russ



More information about the Comp.unix.wizards mailing list