I have a directory containing files named likeSLS20160112.001    (20160112 stands for YYYYMMDD)I wish to archive all previous month's files. For example, given:SLS20150201.001SLS20160107.001SLS20160130.001SLS20160201.001I will archive SLS20160107.001 and SLS20160130.001 because these two files have a January 2016 name and it's currently February 2016.For the SLS20160201.001 (February 2016) should not be archived, as I only want to archive previous month's file. Note that I can only consider the filename, not the mtime or atimeMy current logic is to loop through all files, then get previous month files and then pipe out the filename and tar it. But not sure how to do that part.for file in SLS*; do   f=${file%.*}GET PREVIOUS MONTH FILES AND THEN ECHOdone | tar cvzf SlSBackup_<PREVIOUS_MONTH>.TAR.GZ -T-
Unix Shell script archive previous month file
bash;shell