[英]Listout file created on sunday using shell script
**I have files in my directory. **我的目录中有文件。 Files name is as below.文件名如下。
Now I need to listout files created on sunday.现在我需要列出周日创建的文件。 Expected out put :预期输出:
Backup-2018-08-05.tar.gz备份-2018-08-05.tar.gz
2.Connectly-2018-08-05-05.tar.gz 2.Connectly-2018-08-05-05.tar.gz
** How can I do this task in Shell Script ** 如何在 Shell Script 中执行此任务
May be done using bash regex and GNU date可以使用 bash regex 和 GNU date 完成
for file in *; do
if [[ $file =~ .*([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]).* ]] &&
[[ Sunday = `LANG=C /usr/bin/date -d${BASH_REMATCH[1]} +%A` ]]; then
echo "$file"
fi
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.