简体   繁体   中英

Bash - list files within date range

I'm trying to list files last modified in july of this year, with bash.

So far I've been basing my efforts around this blog * and have come up with:

startdate=”201407010000?
enddate=”201408010000?
touch -t $startdate ./startdatefiles
touch -t $enddate ./enddatefiles
find ./ -type f -newer ./startdatefiles ! -newer ./enddatefiles -ls

I get the following error:

touch: invalid date format `201408010000?'

Does any one know of a straight forward way to do this?

EDIT :

* Nb The blog has since been updated

Somehow the blog post got the code messed. Quotes must be ASCII quotes and should be paired in assignment value:

startdate="201407010000"
enddate="201408010000"

Actually since the value (timestamp) doesn't contain spaces, quotes are not necessary here. It can be written:

startdate=201407010000
enddate=201408010000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM