Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 从ash命令在文本文件中查找和替换_String_Replace_Busybox_Ash - Fatal编程技术网

String 从ash命令在文本文件中查找和替换

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

我需要在一个运行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, 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文件中的数据输入到脚本中,我认为您已经被卡住了