- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
简而言之,我正在尝试查找重复文件(已从 FTP 站点下载,它是另一个脚本文件)并通过电子邮件向企业发送有关所有重复文件及其相应修改日期的信息。
文件/path/test_mail.txt
每行包含一个文件名(在本例中为两个文件名),例如。
abc.xlsx
def.xlsx
for val in '/path/test_mail.txt'; do
{ stat path/$val | grep 'Modify: ' | cut -d' ' -f2,3,4 | awk -F"." '{print $1}' ; } |
$val
done |
mail -s "Duplicate file found ${DATE}" abc@xyz.com
for val in '/path/tj_mail.txt'; do
{ ls -ltr /path/$val | cut -d' ' -f6,7,8 | find $val / -path
$val
done |
mail -s "Duplicate file found ${DATE}" abc@xyz.com
Duplicate Filename - xyz.xlsx Uploaded time - 2020-02-17 11:18:10
Duplicate Filename - abc.xlsx Uploaded time - 2020-02-17 11:18:10
{
DATE=`date +"%Y-%m-%d"`
dirname=/path
tempfile=myTempfileName
find $dirname -type f > $tempfile
cat $tempfile | sed 's_.*/__' | sort | uniq -d|
while read fileName
do
grep "$fileName" $tempfile
done
} | tee '/path/tj_var.txt' | awk -F"/" '{print $NF}' | tee '/path/tj_var.txt' | sort -u | tee '/path/tj_mail.txt' | mail -s "Duplicate file found ${DATE}" abc@xyz.com
path = /marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation
printf "%s" "$(</marketsource/scripts/tj_mail.txt)" | while IFS= read -r filename; do
mtime=$(stat -c %y "/path/$filename")
printf 'Duplicate Filename - %s Uploaded time - %s\n' "$filename" "$mtime"
done | mail -s "Duplicate file found ${DATE}" tipalli@allegisgroup.com
mtime=$(stat -c %y "/path/$filename" 2>/dev/null || echo "unknown (stat failed)")
./tj_mail1.ksh: line 1: path: command not found stat: cannot stat `/path/AirTimeActs_2020-02-08.xlsx': No such file or directory
{
DATE=`date +"%Y-%m-%d"`
dirname=/marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation
tempfile=myTempfileName
find $dirname -type f > $tempfile
cat $tempfile | sed 's_.*/__' | sort | uniq -d|
while read fileName
do
grep "$fileName" $tempfile
done
}
if ["$fileName" == ""]; then
mv /marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/*.xlsx /marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/Archive
mv /marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/*.csv /marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/Archive
exit 1
fi | tee '/marketsource/scripts/tj_var.txt' | awk -F"/" '{print $NF}' | tee '/marketsource/scripts/tj_var.txt' | sort -u | tee '/marketsource/scripts/tj_mail.txt'
DATE=`date +"%Y-%m-%d"`
printf "%s\n" "$(</marketsource/scripts/tj_mail.txt)" | while IFS= read -r filename; do
mtime=$(stat -c %y "/marketsource/SrcFiles/Target_Shellscript_Autodownload/Airtime_Activation/$filename")
printf 'Duplicate Filename - %s Uploaded time - %s\n\n' "$filename" "$mtime"
done | mail -s "Duplicate file found ${DATE}" ti@allegisgroup.com
最佳答案
我假设文件 /path/test_mail.txt
已由其他脚本准备(作为重复文件列表),任务是添加 /path/test_mail.txt
中列出的文件的修改时间。并按照问题所示格式化输出。
while IFS= read -r filename; do
mtime=$(stat -c %y "/path/$filename")
printf 'Duplicate Filename - %s Uploaded time - %s\n' "$filename" "$mtime"
done < "/path/test_mail.txt"
/path/test_mail.txt
你也可以把它添加到这样的管道中
somehow_print_duplicate_file_names | while IFS= read -r filename; do
mtime=$(stat -c %y "/path/$filename")
printf 'Duplicate Filename - %s Uploaded time - %s\n' "$filename" "$mtime"
done | somehow_send_mail
stat
失败。
mtime=$(stat -c %y "/path/$filename" 2>/dev/null || echo "unknown (stat failed)")
stat
的错误信息
mtime=$(stat -c %y "/path/$filename" 2>&1)
关于linux - Bash 脚本自动通过电子邮件发送变量文件名和相应的修改日期时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60491730/
我在 Java 中遇到异常处理问题,这是我的代码。当我尝试运行此行时出现编译器错误:throw new MojException("Bledne dane");。错误是: exception MojE
我刚刚开始学习asp.net。在你们的支持下,我希望我能从这个论坛学到更多东西。 我的问题是, 我在 asp.net 页面中有一个 TabContainer1,因为每个选项卡面板中有多个类似 (60)
我是一名优秀的程序员,十分优秀!