#/!bin/sh
# infile is "person's clothes"
infile=$1
outfile=$2
sed -z "s|'|\\'|g;" <$infile >temp.txt
txt=`cat temp.txt`
echo $txt
# displays person's clothes
sed -e "s|paste_area|$txt|" blank.html >"$outfile"
# the relevant part of $outfile is "person's clothes" expecting "person's clothes"
"请添加一些上下文来解释代码部分";请阅读包含的代码
在sed
替换字符串中使用时,需要将$txt
中的所有反斜杠加倍,以使其成为文字。否则,它们将被视为转义前缀。
sed -e "s|paste_area|${txt/\/\\}|" blank.html >"$outfile"