String 从ash命令在文本文件中查找和替换
我需要在一个运行ashshell和limitedbusybox的相当小的嵌入式系统上修改几个html文件中的href url。唯一可用的功能是:String 从ash命令在文本文件中查找和替换,string,replace,busybox,ash,String,Replace,Busybox,Ash,我需要在一个运行ashshell和limitedbusybox的相当小的嵌入式系统上修改几个html文件中的href url。唯一可用的功能是: ash, brctl, chmod, cp, dnsd, free, halt, ifconfig, init, kill,ls, mkdir, mknod, mount, mv, ping, poweroff, printf, ps, reboot, rm, route, sh, sleep, syslogd, telnetd, umount, vc
ash, brctl, chmod, cp, dnsd, free, halt, ifconfig, init, kill,ls, mkdir, mknod, mount, mv, ping, poweroff, printf, ps, reboot, rm, route, sh, sleep, syslogd, telnetd, umount, vconfig, wc
所以,没有sed,没有回声,等等。。。
我需要找到一个模式匹配解决方案
我发现了这个ksh技巧:
alpha='This is a test string in which the word "test" is replaced.' beta="${alpha//test/replace}"
但它似乎不适用于ash:syntax error:Bad substitution
感谢您的帮助!
谢谢替换很糟糕,因为您在alpha之后使用了两个正斜杠。您想要的模式是${VARIABLE/FINDSTR/REPLACEMENT}。例如:
A="foobar" && echo ${A/foo/bar}
但是,似乎没有将字符串从文件读入变量的命令。也就是说,没有猫,没有头,没有尾巴
因此,如果没有某种方法将HTML文件中的数据输入到脚本中,我认为您已经被卡住了