linux - 正则表达式: Search a word and append a new word at the end of the line

标签 linux perl sed

我有一些 TCL 文件,其中包含许多这样的行。

unp classification ip-address $env(SOURCE_IP4) mask 255.255.255.0

不幸的是我忘记在最后加上一个词(边缘轮廓)。应该是这样的。

unp classification ip-address $env(SOURCE_IP4) mask 255.255.255.0 edge-profile. 

有人可以告诉我如何通过关键字“unp分类ip-address”搜索该行并在行末尾附加单词“edge-profile”。我需要更改多个文件。一行 perl 或 sed 脚本就很好了。

最佳答案

sed -i '/unp classification ip-address/s/$/ edge-profile/' *.tcl

关于linux - 正则表达式: Search a word and append a new word at the end of the line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18186989/

相关文章:

Perl - 以相反顺序逐行读取文件

perl - 剪切和粘贴 shell 命令是否有 Perl 替代品?

linux - 将文件内容复制到目标文件。在目标文件中最后一次匹配模式之后。原始文件的内容显示在目标文件的下一行

linux - 压缩和删除具有特定年龄的文件

php - 修复在 Linux 上运行的 PHP 中的时间格式警告

perl - 如何使用 B::Concise 为所有函数转储操作

bash - 如何在 BASH 中包含匹配模式的任何行之前添加#?

c - 线程在函数返回后停止

ruby - compass 安装在 WebSpace : Command not found

linux - 如何从命令行中删除流中的最后一行