如何查找包含正则表达式的行,并在Android上的文件中替换该行

时间:2017-06-01 08:46:47

标签: android replace vi

我正在尝试使用regexp在文件中找到一行,并用新行替换该行。我想在Android上的命令行上执行此操作。

我以为我可以使用vi这样做:

vi +"%s/ro.streaming.video.drs.*/ro.streaming.video.drs=false/g | x" | build.prop

替换包含以下内容的行:

  

ro.streaming.video.drs =真

使用:

  

ro.streaming.video.drs =假

但是,我注意到BusyBox中的vi 1.1.6.1不支持命令。实际上它根本不支持太多。还有另一种方法可以在Android上实现相同的功能吗?

1 个答案:

答案 0 :(得分:1)

您是否尝试过BusyBox的@SuppressWarnings("ALL") @Configuration @EnableWebSecurity public class MyWebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { List<String> ipAddresses = new ArrayList<>(); ipAddresses.add("127.0.0.1"); ipAddresses.add("192.168.1.0/24"); ipAddresses.add("0:0:0:0:0:0:0:1"); for (String ip : ipAddresses) { http.authorizeRequests(). antMatchers("/admin" + "/**") .access("hasRole('admin') and hasIpAddress('" + ip + "')"); } } //some other configurations }

sed

甚至

sed -i 's/ro.streaming.video.drs.*/ro.streaming.video.drs=false/g' build.prop