A gopher phlogroll in a POSIX shell script
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
phrollo/phrollo

17 lines
503 B

#!/bin/sh
# (c) 2019 KatolaZ <katolaz@freaknet.org>
# MIT License
FILEIN="${1:-/dev/stdin}"
IFS=' '
while read -r D T S H P SH; do
NSH="$(printf "$S\r\n" | nc "$H" "$P" | shasum -a 256 | cut -d " " -f 1)"
[ $? -eq 0 ] &&
[ "${SH}" != "${NSH}" ] && {
D="$(date +%Y%m%d)"
SH="${NSH}"
}
printf "%s\t%s\t%s\t%s\t%s\t%s\n" "$D" "$T" "$S" "$H" "$P" "$SH" | tee /dev/stderr
done < "${FILEIN}" | sort -rnk1 -k2 | \
sed -r "s/^([0-9][0-9]*) /1(\1) /g;s/ [a-f0-9][a-f0-9]*$//g" |\
sort -rk1 -k2