[英]Bash Script read hostnames from .txt file and place in variable for ssh
[英]Bash script to Comparing list of variable filenames from one txt file to another and do something in linux
我的目的是一一读取 temp11 文件中的文件名,并将其与 tj_mail.txt 中的文件名进行比较
如果匹配,则什么都不做,如果不匹配,则将文件从目的地移动到另一个。
temp 11 有 abc.xlsx 和 tj_mail.txt 有 /path1/path2/abc.xlsx
因为它们不匹配,所以应该执行移动操作
cat /mae/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/temp11 | while IFS="" read -r -d $'\0' file;
do
read "${file?}"
if grep -qF "$$file" /mae/scripts/tj_mail.txt;then
:
else
mv $file /marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/newthings
fi
done
没有错误,但也没有做任何事情,似乎没有读取文件
没有必要使用read
和grep
。 使用comm
比较两个文件并获取丢失的文件,并将它们传递给mv
。
comm -23 <(sort /mae/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/temp11) <(sort /mae/scripts/tj_mail.txt) |
xargs mv -t /marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/newthings
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.