[英]How to search file and insert string after match in ruby?
I have the following code in bash: 我在bash中有以下代码:
sed \"s/\:root\:/\:root-$(hostname)\:/g\" /etc/passwd
That results in: 结果是:
root:x:0:0:root-myhostname.domain.tld:/root:/bin/bash
I'm trying to duplicate the same behavior in Ruby. 我正在尝试在Ruby中复制相同的行为。 Can someone please help me? 有人可以帮帮我吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.