regex - Linux用连续数字替换特定字符串
问题描述
CONFIG.CONFIG
create state file${number_of_edges} {
{interval=60
idle_interval_notification="DISABLED"}
}
create state file${number_of_edges} {
{interval=60
idle_interval_notification="DISABLED"}
}
我有文件,其内容如上。我想用 0,1,2 等连续数字替换 ${number_of_edges} 字符串
EXPECTED OUTPUT
create state file0 {
{interval=60
idle_interval_notification="DISABLED"}
}
create state file1{
{interval=60
idle_interval_notification="DISABLED"}
}
create state file2 {
{interval=60
idle_interval_notification="DISABLED"}
}
解决方案
我得到了解决方案。
命令-
awk -vRS=edge '{$0=n$0;ORS=RT}++n' FILE
推荐阅读
- cordova - 如何隐藏/删除 Ionic 4 Cordova Windows 10 应用程序后退按钮?
- python - 在 Python 中打印具有相应值的数组索引
- excel - 如果数组包含某些文本(例如,如果 rRng(i,k) 包含“/2”),如何使用 select case 语句
- angular - Angular 7处理大型post http请求
- python - 如何在 JSONField 中找到最大/最小值?
- javascript - (WebGL)如何将顶点添加到已经初始化的顶点缓冲区?
- javascript - 为什么当我更改原始数组/对象时,复制的数组/对象会发生变化?
- php - Laravel 根路由“/”在子域的前缀路由中不起作用
- ios - 如何防止 iOS 13 中的 uinavigationbar 和视图之间的间隙?
- mongodb - 更改默认的 MongoDB ObjectID 生成器