尝试编写test1.ksh,其中包含用于搜索“%s_sitename%”字符串并将其替换为“%s_sitename%”的命令,并且今天在文件test.sql中显示日期:
s1='%s_sitename%' s2=echo date "+%Y-%b-%e" s3=$s1$s2 sed -i 's/'"$s1"'/'"$s3"'/g' test.sql exit
s2=echo date "+%Y-%b-%e"
is wrong. First you don't need echo, second you didn't enclose the command inside backticks (``)
s1='%s_sitename%'
s2='%s_sitename%'"$(date "+%Y-%b-%e")"
sed -i 's/'"$s1"'/'"$s2"'/g' test.sql
Should do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.