summaryrefslogtreecommitdiff
path: root/phrollo
diff options
context:
space:
mode:
Diffstat (limited to 'phrollo')
-rwxr-xr-xphrollo27
1 files changed, 27 insertions, 0 deletions
diff --git a/phrollo b/phrollo
new file mode 100755
index 0000000..1e2ff91
--- /dev/null
+++ b/phrollo
@@ -0,0 +1,27 @@
+#!/bin/sh
+# (c) 2019 KatolaZ <katolaz@freaknet.org>
+# MIT License
+
+FILEIN="${1:-/dev/stdin}"
+TODAY="$(date +%Y%m%d)"
+if [ "${FILEIN}" != '/dev/stdin' ]; then {
+ cat "${FILEIN}" | tee "${FILEIN}".bak > "${FILEIN}".new
+ FILEOUT="${FILEIN}".new
+} else {
+ FILEOUT="$(basename $0).out"
+}
+fi
+
+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="${TODAY}"
+ SH="${NSH}"
+ }
+ printf "%s\t%s\t%s\t%s\t%s\t%s\n" "$D" "$T" "$S" "$H" "$P" "$SH"
+done < "${FILEIN}" | sort -rnk1 -k2 | tee "${FILEOUT}" | \
+ sed -r "s/^([0-9][0-9]*) /1(\1) /g;s/ [a-f0-9][a-f0-9]*$//g" |\
+ sort -k1 -k2
+