2018-03-01 22:25:05 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
if [ "$#" -ne 1 ] || [ "$1" = "--help" ] || [ ! -f "$1" ]; then
|
|
|
|
echo "This script fixes replies ids in QEMU replies files."
|
|
|
|
echo ""
|
|
|
|
echo " Usage: $0 path/to/qemu.replies"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
awk -i inplace \
|
2018-06-19 19:51:00 +08:00
|
|
|
'BEGIN {last=0; pattern="libvirt-[0-9]+"}
|
2018-03-01 22:25:05 +08:00
|
|
|
{
|
|
|
|
if (match($0, "libvirt-1[^0-9]")) {
|
|
|
|
count=1;
|
|
|
|
}
|
|
|
|
if (match($0, pattern)) {
|
|
|
|
str="libvirt-" count;
|
|
|
|
sub(pattern, str, $0);
|
2018-06-19 19:51:00 +08:00
|
|
|
if (last != count) {
|
|
|
|
last=count;
|
|
|
|
} else {
|
|
|
|
count++;
|
|
|
|
}
|
2018-03-01 22:25:05 +08:00
|
|
|
}
|
|
|
|
print
|
|
|
|
}' "$1"
|