You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
350 B
21 lines
350 B
#!/bin/sh
|
|
|
|
usage() {
|
|
echo "usage: $0 [-h] [NAME=NEWNAME...]" >&2
|
|
}
|
|
|
|
while getopts h opt; do
|
|
case "$opt" in
|
|
h) usage; exit 0;;
|
|
?) usage; exit 255;;
|
|
esac
|
|
done
|
|
shift $(($OPTIND-1))
|
|
|
|
pipe=.
|
|
for arg; do
|
|
old="${arg%%=*}"
|
|
new="${arg#*=}"
|
|
pipe="$pipe | .[\"$new\"] = .[\"$old\"] | del(.[\"$old\"])"
|
|
done
|
|
exec jq -M -c "$pipe"
|
|
|