Question: I am new to Unix Shell script. I need to keep file for retention period of one month and archive other.

Example:

File format: WE20160225.log (20160225 YYYYMMDD)

Say in the directory /oracle/Sales has 3 files:

WE20160130.log

WE20151201.log

WE20151109.log

I need to tar.gz the WE20151201.log and WE20151109.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 substring the date from file and check with current date

**I need to use the filename date, not the file modification date.**

```
SALES_DIR="/oracle/sales/"
cd $SALES_DIR

```

Answer: 
some simple `if`'s will work:

```
 $("#plus3").click(function () {

    var value = $("#slider-range-max3").slider("value");
    var step = $("#slider-range-max3").slider("option", "step");

    if(value < (sizes.length-1)){
      $("#slider-range-max3").slider("value", value + step);
      $("#sup").val(sizes[value+step]).text(sizes[value+step]);
    }
  });

  $("#minus3").click(function () {

    var value = $("#slider-range-max3").slider("value")
    var step = $("#slider-range-max3").slider("option", "step");

    if(value){
      $("#slider-range-max3").slider("value", value - step);
      $("#sup").val(sizes[value-step]).text(sizes[value-step]);
    }
  });

```

[**Fiddle**](https://jsfiddle.net/uq4eakah/1/)
If you only alter the text inside the slider's change event and not in the button themselves, you don't need any additional checking (the slider won't change to invalid ranges):

```
  var sizes = [ "0 years", "1 year", "2 years", "3 years", "4 years", "5 years", "6 years", "7 years" ];
  var slider = $("#slider-range-max3").slider({
    range: "max",
    min: 0,
    max: sizes.length - 1,
    step: 1,
    create: function(event, ui) {
      $("#sup").val(sizes[0]);
    },
    slide: updateText,
    change: updateText
  });

  function updateText(event, ui){
        $("#sup").val(sizes[ui.value]);
  }

  function Inc(step){
    slider.slider("value", slider.slider("value") + step);
  }

  $("#plus3").click(function () {
    Inc(1);
  });

  $("#minus3").click(function () {
    Inc(-1);
  });

```

[Fiddle](https://jsfiddle.net/uq4eakah/6/)

Alternatively or additionally, you could skip using the array and build the text dynamically (with the only exception being the omitting of the trailing s on '1 year' )

*edit* For completeness sake, an example implementation without the sizes array: <https://jsfiddle.net/uq4eakah/7/>