获取文件时间:
[root@ ~]# ls --full-time beforedate.txt
-rwxr-xr-x 1 root root 27 2019-08-12 16:54:31.137000000 +0800 beforedate.txt
[root@ ~]# ls --full-time beforedate.txt| cut -d ' ' -f 6
2019-08-12
[root@ ~]# ls --full-time beforedate.txt| cut -d ' ' -f 7
16:54:31.137000000
[root@ ~]# ls --full-time beforedate.txt|awk '{print $6 " " $7}'
2019-08-1216:54:31.137000000
[root@ ~]# ls --full-time beforedate.txt |awk '{print $6 " " $7}' |cut -d '.' -f 1
2019-08-12 16:54:31
获取系统时间:
[root@ ~]# echo `date +%Y-%m-%d` `date +%H:%M:%S`
2019-09-27 14:41:23
------------------------实例------------------------
#!/bin/bash
#
#功能:查找指定日期范围内的文件,然后压缩打包。
#
BDATE=$(echo