From 442bbc2cfd5c4f81f7de11a0b5b8145204cdea32 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 9 Apr 2017 22:11:53 -0700 Subject: [PATCH] revert chost, broke for localhost --- chost | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chost b/chost index 77e17d4..3e1acd2 100755 --- a/chost +++ b/chost @@ -7,6 +7,7 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR host=$1 -addr=$(getent hosts $host | awk '{print $1}') -h=$(getent hosts $addr | awk '{print $2}') +addr=$(host $host | sed -rn 's/^.*has address (.*)/\1/p;T;q') +h=$(host $addr) +h=${h##* } echo ${h%%.*} -- 2.30.2