Files
svr/usr/bin/grepkey
T

20 lines
296 B
Bash
Raw Normal View History

2026-01-23 08:55:18 +01:00
#!/usr/bin/bash
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then
echo "Usage: $0 key"
echo "Usage: grep values after key=value"
exit 1
fi
awk -v key="$1" '{
for (i = 1; i <= NF; i++)
if ($i ~ "^"key"=") {
split($i, a, "=")
print a[2]
}
}' # | cut -d\ -f 1
exit 0