Replace grep|awk|tail by just awk

This commit is contained in:
Loic Nageleisen 2020-04-13 12:03:06 +02:00
parent 00d9c4051d
commit d2dd80d9f0

View file

@ -25,7 +25,7 @@ function kd() {
fi fi
if [[ $# -eq 1 ]]; then if [[ $# -eq 1 ]]; then
local target 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 [[ -n "$target" ]]; then
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
cd "$target" || return 1 cd "$target" || return 1