[comp.unix.shell] A one-liner to find files in archive servers

cedman@golem.ps.uci.edu (Carl Edman) (12/21/90)

This is a little one-liner I wrote and decided to share with my fellow
unix-shell programmers in the spirit of Xmas. :-).

Archie is a service available via telnet which collects and
distributes the file listings of a large number of publicly accessible
ftp servers. This script is a frontend to it. Just type "archie
foobar" where foobar is any regular expression contained in the
program you search, wait a little while, and get the listing of all
anon ftp servers which contain versions of this file, sorted newest
versions first. Example output:

~> archie amoeba
Oct 23 1990   46343 /uafcseg.uark.edu:/amiga/new_uploads/amoeba.lzh
Oct 22 1990      44 /sachiko.acc.stolaf.edu:/home/sachiko/cdr/work/Installs/acc/NIC_files/DONE/aliases.amoeba
Oct 22 1990     760 /ucece1.ece.uc.edu:/pub/biblio/world/opsys/amoeba
Oct 12 1990     512 /quiche.cs.mcgill.ca:/pub/amoeba
Sep 12 1990     512 /stolaf.edu:/pub/amoeba
Aug 19 1990    1024 /watmsg.waterloo.edu:/pub/amoeba
[ ... more of the same ... ]
Jul 17 1988  128605 /mrcnext.cso.uiuc.edu:/ux1/amiga/fish/ff120/amoeba.zoo
Jul 17 1988  128605 /ux1.cso.uiuc.edu:/amiga/fish/ff120/amoeba.zoo

This is only tested under HPUX, but apart from 'remsh' which probably
is 'rsh' on your system, it doesn't use any HPUX specifics.

I just wrote this because I needed it, but if you find it useful feel
free to let me know :-).

        Carl Edman

------------------------- Cut here -----------------------------------
#! /bin/sh
# A little one-line script to call up archie, get the list of all files specified
# by the regular expression which is the first argument, sort these files by age
# and display them
echo "prog $1" | remsh quiche.cs.mcgill.ca -l archie "" | nawk "/Host/ { host = \$2 } /Last/ { cury = \$6 } /Location:/ { dir = \$2 } /FILE/||/DIRECTORY/ { if (index(\$6,\":\")) year = cury; else year = \$6; printf \"%3s %2s %4s %7s /%s:/%s/%s\\n\",\$4,\$5,year,\$3,host,dir,\$7 } { next }" - | sort +2nr -3 +0Mr -1 +1nr -2
------------------------- Cut here -----------------------------------

Theorectical Physicist,N.:A physicist whose  | Send mail
existence is postulated, to make the numbers |  to
balance but who is never actually observed   | cedman@golem.ps.uci.edu
in the laboratory.                           | edmanc@uciph0.ps.uci.edu

cedman@golem.ps.uci.edu (Carl Edman) (12/22/90)

I'm informed that some people are having problems with the script,
which disappear when using 'gawk' instead of 'nawk'. If you are having
problems, try that. (And if that still doesn't work, mail me).

Also for systems which don't resolve internet-name into addresses
automatically , here are the internet addresses for
quiche.cs.mcgill.ca:

      132.206.2.3 or 132.206.51.1

        Carl Edman



Theorectical Physicist,N.:A physicist whose  | Send mail
existence is postulated, to make the numbers |  to
balance but who is never actually observed   | cedman@golem.ps.uci.edu
in the laboratory.                           | edmanc@uciph0.ps.uci.edu