我有以下配置文件:
servers = (
{
host = "localhost";
...
timeout = 5;
},
{
host = "127.0.0.1";
...
timeout = 0;
},
{
host = "example.com";
...
timeout = 99;
}
);
我想在每个部分的末尾附加“索引”设置,因此配置如下所示:
servers = (
{
host = "localhost";
...
timeout = 5;
index = 1;
},
{
host = "127.0.0.1";
...
timeout = 0;
index = 2;
},
{
host = "example.com";
...
timeout = 99;
index = 3;
}
);
如何使用sed或awk等传统的 Unix 工具来做到这一点?