From d2dd80d9f072d34f717c3e135a19e14b0d7e8d7b Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Mon, 13 Apr 2020 12:03:06 +0200 Subject: [PATCH] Replace grep|awk|tail by just awk --- shell/kd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/kd b/shell/kd index f7357c6..9de040a 100755 --- a/shell/kd +++ b/shell/kd @@ -25,7 +25,7 @@ function kd() { fi if [[ $# -eq 1 ]]; then local target - target="$(grep -e "^$1" "$conf" | awk '{ print $2 }' | tail -1)" + target="$(awk "\$1 = /^${1}/ {a=\$2}; END { if (a) {print a}}" "$conf")" if [[ -n "$target" ]]; then if [[ -t 1 ]]; then cd "$target" || return 1