kenk@richsun.UUCP (Ken Konecki) (10/27/88)
With all this talk of scripts to combine postings I though I'd
throw in my 2 cents worth. Here's an awk script that will filter
out all the graft from a multiple post binary. Just specify as
arguments to the script which files to combine. If no files are
specified, it will read from stdin. It will write its output to
stdout. Note that the files will be concatenated in the order
specified.
example: combine binary.1 binary.2 > binary.hqx
This will combine the postings binary.1 and binary.2 to the
BinHex file binary.hqx Note that by having this script there is
NO preprocessing to be done to the postings after you save
them with your favorite news reader.
I've also included a short sed script to remove the 'This file
must be converted...' and blank line immeditaely following from
the BinHex file. For some reason I'm not sure of (maybe someone
can enlighten me) the BinHex program I use (5.0) barfs if those
lines are in the file to be converted. It will read from stdin if
no files are specified and write to stdout. If any arguments are
specified it will remove the two lines from each file specified.
Note that the original file will not be preserved in this case.
example: combine binary.1 binary.2 | bhprep > binary.hqx
This will combine the two postings binary.1 and binary.2, strip
off the two inital lines (but onlyy if they are the 'This
file...' and the immediately following blank line and put it all
into the file binary.hqx Have fun. If you have any questions,
just ask. My address is
...!uunet!richsun!kenk or if that won't work try:
...!purdue!richp1!richsun!kenk
Here's the shar file:
--- 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:
# combine
# bhprep
# This archive created: Thu Oct 27 10:02:15 1988
export PATH; PATH=/bin:$PATH
echo shar: extracting "'combine'" '(327 characters)'
if test -f 'combine'
then
echo shar: will not over-write existing file "'combine'"
else
cat << \SHAR_EOF > 'combine'
#! /bin/sh
# Script: combine
# Author: Ken Konecki
# Date: 20 October 88
# Purpose: To combine multiple postings into one file
exec awk '
BEGIN {
keep = 0;
}
/^---/ || /[Cc][Uu][Tt] [Hh][Ee][Rr][Ee]/ {
if (keep == 1)
keep = 0;
else
keep = 1;
continue;
}
keep == 1 {
print $0
}' "$@"
SHAR_EOF
if test 327 -ne "`wc -c < 'combine'`"
then
echo shar: error transmitting "'combine'" '(should have been 327 characters)'
fi
chmod +x 'combine'
fi # end of overwriting check
echo shar: extracting "'bhprep'" '(451 characters)'
if test -f 'bhprep'
then
echo shar: will not over-write existing file "'bhprep'"
else
cat << \SHAR_EOF > 'bhprep'
#! /bin/sh
# Script: bhprep
# Author: Ken Konecki
# Date: 11 Oct 88
# Purpose: To prepare BinHex files for downloading to the Mac
if [ ${#} -eq 0 ] # Read from stdin
then
sed -e '1,2{/This file must be converted/,/^$/d
}'
else
trap 'rm -f /tmp/prep$$' 1 2 15 EXIT
for i in "$@"
do
echo -n "Prepping $i......."
sed -e '1,2{/This file must be converted/,/^$/d
}' $i > /tmp/prep$$
mv /tmp/prep$$ $i
echo "done"
done
fi
SHAR_EOF
if test 451 -ne "`wc -c < 'bhprep'`"
then
echo shar: error transmitting "'bhprep'" '(should have been 451 characters)'
fi
chmod +x 'bhprep'
fi # end of overwriting check
# End of shell archive
exit 0
--- Cut here ---
--
Ken Konecki
(kenk@richp1.UUCP)
"A squeegee by any other name wouldn't sound as funny"