Selected target files based on file's modification date

! # / bin / bash 
start and due dates # input screening document 
the Read
-p " the INPUT firstTime, like 2018-5-6 2:20:31: " FIRST_TIME
the Read
-p " the INPUT secondtime, like 2019-5- 2. 6: 31 is:. 5: " second_time is #read -p " INPUT the path of Save: " savepath echo $ FIRST_TIME echo $ second_time is IF [-f File .txt] the then Touch File .txt Fi
date format is converted into the # time stamp, to facilitate comparison
FIRST_TIME = ` DATE -d " $ FIRST_TIME" +% S` second_time =` DATE -d " $ second_time " +% s`
# recursive function to traverse directory file, filter out all eligible document in that directory
function the Document () { for File in ` LS $ 1 ` do echo $ . 1 " / " $ File IF [-d $ . 1 " / " $ File ] the then echo $ . 1 " / " $ File IS A Document document $1"/"$file else aim_time=`ls -lt --full-time $1"/"$file | awk '{ print $6,$7 }'` aim_time=`date -d "$aim_time" +%s` if [ "$first_time" -lt "$aim_time" ] && [ "$aim_time"-en" $ Second_time " ] the then echo $ 1 "/" $ File >> File .txt fi fi DONE }
# recursive function parameters are to be screened target directory
the Document $
1

 

Guess you like

Origin www.cnblogs.com/kuangkuangduangduang/p/11130494.html