读取行时sed替换变量 [英] sed replace variables while read lines
本文介绍了读取行时sed替换变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理Shell脚本,我需要将一些字符串从文件的不同行更改为while读取语句.结构必须像这样,因为String_Search和String_result将在每一行上计算.
I'm working on a shell script and i need to change some strings from different lines of a file into a while read statement. The structure need to be like this, because the String_Search and String_result will be calculated on each line.
while read line
do
varA="String_Search"
resA="String_Result"
line=`echo $line | sed -e "s/$varA/$resA"`
echo $line >> outputFile.txt
done < "inputFile.txt"
该脚本无法正常工作,并且向我显示此错误消息:
The script doesn't works and its showing to me this error message:
sed: -e expression #1, char 31: unterminated `s' command
任何人都可以帮助我吗?
Anyone Can Help Me?
感谢所有人
推荐答案
您需要以斜杠/
line=`echo $line | sed -e "s/$varA/$resA/"`
这篇关于读取行时sed替换变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文