【发布时间】:2021-05-29 08:03:04
【问题描述】:
我有 2 个文件,大小都带有 ';'分隔。
old_file
Apple;aaa@abc.com
Banana;bbb@abc.com
carrot;ccc@abc.com
new File
Banana;new@abc.com
我正在创建一个 shell 脚本来检查新文件数据并发送电子邮件,然后它会扫描剩余的 大文件中的数据不匹配并分别发送电子邮件。(对于匹配的值,它应该使用新电子邮件)
我的代码
#Variables
name_old=`awk -F ";" '{print $1} {$temp}`;
email_old=`awk -F ";" '{print $2} {$temp}`;
name_new=`cat 'smallfile' | awk -F ";" '{print $1}'`;
email_new=`cat 'smallfile' | awk -F ";" '{print $2}'`;
///
if #grep -wq $name_new <<< $name_old
[[ "$name_new" == "$name_old" ]]
then
echo "store the matched value email in a variable"
else
echo "store the unmatched value email in a variable"
fi
sample Output can be stored in a variable.
aaa@abc.com
new@abc.com--->matching record so updated email
ccc@abc.com
如果出现任何问题,有人可以查看和更新吗? 我是 shell 脚本的新手,但我正在尝试:)
【问题讨论】: