使用以下方法不行

sed -i 's/\$this_year/\$next_year/g' schema.xml.$next_year

 

使用双引号,变量外边不要使用小括号要是大括号

#!/bin/bash
this_year=$(date +%Y)
next_year=$(date -d next-year +%Y)

sed -i "s/${this_year}/${next_year}/g" schema.xml.$next_year
sed -i "s/${this_year}/${next_year}/g" rule.xml.$next_year 
sed -i "s/${this_year}/${next_year}/g" server.xml.$next_year

 

转载请注明出处!

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2021-12-13
  • 2021-05-17
猜你喜欢
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案