Use `cut` to redact IPs (BSD sed doesn't support backreferences)

This commit is contained in:
Nils Steinger 2017-06-01 18:38:19 +02:00
parent d5b171a9ca
commit d344d0ff16
1 changed files with 8 additions and 1 deletions

View File

@ -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()