我要解析一组密码路径不同的文件,并用新文件进行更改。
例如,我有一个文件pass.lst
,其中包含密码列表
oldpassword1/newpassword1
oldpassword2/newpassword2
oldpassword2/newpassword2
我还有一个包含文件路径列表的文件
path.lst
:
$Home/test.xml
$Home/demo.sh
etc....
现在,我要制作包含脚本的主文件,该脚本从文件中读取输入并完成我的工作 这是我正在使用的脚本
for i in `cat pass.lst`
`do`
for j in `cat path.lst`
do
perl -p -i -e 's/$i/g' $j
done
done
但这给了我这个错误。
Substitution replacement not terminated at -e line 1.
任何建议和帮助将不胜感激。
答案 0 :(得分:0)
#!/usr/bin/env bash
while IFS=/ read -r orig replacement; do
orig="$orig" replacement="$replacement" \
xargs -d $'\n' \
perl -p -i -e 's/$ENV{orig}/$ENV{replacement}/g' \
<path.lst
done <pass.lst