September 22, 2017

How to create jar file based on the incoming files' timestamp?

Let's say I have 10.000 xml files (in reality even more) coming in from external resource at different time of each day. I need to create a jar file based on the timestamp of these files. The jar file will carry today's date. Any xml file coming in after midnight should not be counted in today's jar file. Any suggestion to tweak the following script to meet the requirement?

# package all current day's xml files into a jar file

jar_name=`date "+%m%d%y"`"_xyz.jar"
jar cvf $jar_name xyz*.xml
cp $jar_name /absolute path/$jar_name

 

Click Here!