# # Prasad Chalasani. # A shell script to pick out (blank-line-separated) records # that match given strings. # This only assumes that records (e.g., BIB entries) # are SEPARATED by BLANK LINES, # so as long as no blank lines are INSIDE an entry, this will work. # Example of a call: # ------------------ # cat colt.bib | pick DNF | pick queries | pick "Angluin|Kharitonov" # picks all articles written by Angluin OR Kharitonov that mention # both DNF AND queries. # Any regular expression allowed by egrep can be given as argument to # pick, WITHIN DOUBLE QUOTES (In the simplest case when the # argument is a single string, no quotes are needed.) set preamble = 'BEGIN {RS=""}' set pattern = "/$1/" set action = ' {print; printf "\n"} ' set cmd = "$preamble $pattern $action" awk "$cmd"