From d344d0ff16b7dd3af48435b502d31e53e286987d Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 1 Jun 2017 18:38:19 +0200 Subject: [PATCH] Use `cut` to redact IPs (BSD sed doesn't support backreferences) --- nench.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nench.sh b/nench.sh index 8c2b46b..f9f243f 100755 --- a/nench.sh +++ b/nench.sh @@ -30,7 +30,14 @@ B_to_MiB() redact_ip() { - printf '%s\n' "$1" | sed 's!\(\([0-9a-f]\+[.:]\)\{3\}\).\+!\1xxxx!' + case "$1" in + *.*) + printf '%s.xxxx\n' "$(printf '%s\n' "$1" | cut -d . -f 1-3)" + ;; + *:*) + printf '%s:xxxx\n' "$(printf '%s\n' "$1" | cut -d : -f 1-3)" + ;; + esac } finish()