unix - Regex & ls or find -


i need select directories between periods of 20140729 - 20140921.

the directories this.

20140729_154208 20140814_221350 20140829_215623

what best method this?

thanks

using find

in order find files modified within range, if creation time of last file in directory matches directory name, easiest way create files @ boundaries of range , use -newer predicate.

touch -t 201407290000 start touch -t 201409210000 stop find . -newer start \! -newer stop -type d 

(i know not how work dates within regex, hope have time learn)

using awk

yeah, why not using awk instead of building static regex match case?

pass find or ls result awk little program checking result between stop , start (nb: find had substr(3,10) comparison):

find .  |awk -v start=20140729 -v stop=20140921 \ '{ curr=substr($0, 3, 10); if (curr <= stop && curr >= start) { print $0 } }' 

(it worked me on aix , linux)


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -