I am new to bash script. I need to keep file for retention period of one month and archive other.
File format: WE20160225.log (20160225 YYYYMMDD)
Say in the directory
/oracle/Sales has 2 files:
I need to tar the WE20151201.log
But not WE20160130.log because the file is less than one month from now. How can I do this? (probably need to substring the filename)
I'm able to change directory but don't know what to do next. My logic is loop through the file and get the date from filename, then compare with current date.
I need to use the filename date, not the file modification date.
SALES_DIR="/oracle/sales/" cd $SALES_DIR