carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (05/19/88)
I decided it was time to learn a bit of awk and upgrade our FishList searching capabilities here on cbmvax. The following shar contains getfish.doc and the getfish command (getfish shell script and gfawk1 awk script). If you have a FishList on your system, some slight editing (see getfish.doc) will allow you to use getfish to output the disk numbers, program names, and program descriptions of all programs which match any of the patterns you supply. Example: getfish "[dD]river|[sS]erial" Any constructive tutorial criticisms of my programming style (or lack thereof) should be emailed to me, not posted. I'm new at this stuff :-) Ms. Cat ------------------------------ cut here ---------------------------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # getfish.doc # getfish # gfawk1 # This archive created: Wed May 18 13:54:14 1988 export PATH; PATH=/bin:$PATH if test -f 'getfish.doc' then echo shar: will not over-write existing file "'getfish.doc'" else cat << \SHAR_EOF > 'getfish.doc' Getfish.doc =========== GETFISH Extract info from FishList by Carolyn Scheppner CBM 05/88 (cbmvax!carolyn) Notes: 1. If you have the complete FishList available on your system, this shell script "getfish" and partial awk script "gfawk1" can be used to extract the Disk number, program names, and descriptions of all programs which match the patterns you provide. 2. Some slight editing must be done on your FishList to make sure that every disk listing begins with "DISK number" on a separate line. Most of this editing can be accomplished with a global replace of "CONTENTS OF DISK" with "DISK". 3. This shell script "getfish" requires the partial awk script "gfawk1" and expects both gfawk1 and FishList to be in the directory $GFDIR. In the first line, equate GFDIR to the directory where you have placed gfawk1 and your FishList. Put "getfish" somewhere in your command path and rehash. 4. Examples Find all programs containing "Blitter" or "blitter": getfish "[bB]litter" Find all containing "driver", "Driver", "serial", or "Serial": getfish "[dD]river|[sS]erial" Find all descriptions mentioning RAM (screen out "program", etc.) getfish " [rR]am| RAM" Pipe output to more: getfish "[dD]river" | more Redirect output to a file: getfish "[dD]river" > tmpfile 5. This script currently prints out a Usage line if called with no arguments. I understand this is considered a bad-thing-to-do by some. So if you don't like it, don't complain. Just change it. This is my first encounter with awk, so if any awk experts see ways to improve or speed up gfawk1, let me know. The final line of the awk script is generated below in an echo command. The completed awk script is stored as .tmpgfawk in the user's directory. SHAR_EOF fi # end of overwriting check if test -f 'getfish' then echo shar: will not over-write existing file "'getfish'" else cat << \SHAR_EOF > 'getfish' #!/bin/sh # GETFISH extract info from fish list C. Scheppner 05/88 # GFDIR="/usr/spool/uucppublic/software" usage="USAGE: getfish \"[mM]atch\" OR getfish \"[mM]atch1|[mM]atch2|etc.\"" # Check that a pattern has been provided case $# in 0) echo $usage ;; 1) echo "if(\$0~/"$1"/) found=1 }" | cat $GFDIR/gfawk1 - > $HOME/.tmpgfawk awk -f $HOME/.tmpgfawk $GFDIR/FishList ;; *) echo $usage ;; esac SHAR_EOF chmod +x 'getfish' fi # end of overwriting check if test -f 'gfawk1' then echo shar: will not over-write existing file "'gfawk1'" else cat << \SHAR_EOF > 'gfawk1' /^DISK/ { thisdisk = $2 } { if(substr($0,1,1) > " ") { if(found) { if(progdisk != showndisk) { print "================" print "DISK: " progdisk showndisk = progdisk } print " " print progdesc print " " } progname = $1 progdisk = thisdisk progdesc = "" found = "" } if(length(progdesc) < 940) progdesc = progdesc RS $0 SHAR_EOF chmod +x 'gfawk1' fi # end of overwriting check # End of shell archive exit 0 -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Carolyn Scheppner -- CATS >>Commodore Amiga Technical Support<< UUCP ...{allegra,ihnp4,rutgers}!cbmvax!carolyn PHONE 215-431-9180 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
tope@enea.se (Tommy Petersson) (05/20/88)
Perhaps someone could email me the FishList? I would be pleased.
carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (05/24/88)
In article <3319@enea.se> tope@enea.se (Tommy Petersson) writes: > >Perhaps someone could email me the FishList? > >I would be pleased. If it's OK with Fred Fish, I will send my already-edited-for-getfish FishList to the amiga sources newsgroup. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Carolyn Scheppner -- CATS >>Commodore Amiga Technical Support<< UUCP ...{allegra,ihnp4,rutgers}!cbmvax!carolyn PHONE 215-431-9180 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=