summaryrefslogtreecommitdiff
path: root/phrollo
diff options
context:
space:
mode:
Diffstat (limited to 'phrollo')
-rwxr-xr-xphrollo19
1 files changed, 3 insertions, 16 deletions
diff --git a/phrollo b/phrollo
index 4f6f67b..55fb5d8 100755
--- a/phrollo
+++ b/phrollo
@@ -3,25 +3,12 @@
# 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}" | \
+ [ "${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
-