Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!acorn!aglover From: aglover@acorn.co.uk (Alan Glover) Newsgroups: comp.sources.acorn Subject: Extracting binaries with Un*x - an AWK script Message-ID: <7075@acorn.co.uk> Date: 15 May 91 07:58:49 GMT Sender: aglover@acorn.co.uk Distribution: comp Organization: Acorn Computers Ltd, Cambridge, England Lines: 50 Approved: aglover@acorn.co.uk There have been several questions recently about how to handle comp.binaries.acorn postings on a un*x box. Here's one way..... Because of the way !Extract works, and tries to be filing system/path independent, it is not possible for the filename to be anything other than the one used. However, below is an AWK script which will combine the parts together and uudecode them, then rename the file to either "tar.Z" or just "tar" if it wasn't compressed. The syntax for the script is decode part1 part2 part3 ... --Philip Colmer (pcolmer@acorn.co.uk) #!/bin/awk -f # This is specific to the format used in comp.binaries.acorn, # in particular it recognises the !Submit, !Extract structure. BEGIN {ok=0;decoding=0;file=""} # Following recognises the first begin line /begin [0-9][0-9][0-9] / {ok=1;decoding=1;file=$3} # And these are for subsequent archives /begin part / {if (decoding) ok=1; next} # Following is in case the archive headers are removed /^M/ && (length == 61 || length == 62) {if (decoding) ok=1} # The end of an archive /^include/ {ok = 0;next} # And just in case it is truncated /^From:/ {ok = 0;next} /^Path:/ {ok = 0;next} /^Message/ {ok = 0;next} # If ok decode the archive {if (ok) print | "uudecode" } # The archive end is marked by end at the line start /^end/ {ok = 0;decoding=0;} # Fix up the file name END{ if (filename = ".Work.File-Z") print | "mv '" filename "' tar.Z"; else if (filename = ".Work.File") print | "mv '" filename "' tar"; } Alan-------------------------------------------------------------------------- aglover@acorn.co.uk - Moderator of comp.binaries.acorn/comp.sources.acorn Mail submissions to submit@acorn.co.uk, other mail to moderator@acorn.co.uk