From 29b88760a160dc5db087a6dd973211c20508ba54 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Mon, 28 Jan 2019 06:14:11 +0000 Subject: new config file on stderr + amend README --- phrollo | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'phrollo') 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 - -- cgit v1.2.3