Skip to main content
deleted 2 characters in body
Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88

Try this,

 last_day=20190426
 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input fallsfall on 5th(fridayFriday) day of the week will add 3.
  • if input fallsfall on 6th(saturdaySaturday) day of the week will add 2.
  • else add 1 for all other days of the week

Try this,

 last_day=20190426
 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input falls on 5th(friday) day of the week will add 3.
  • if input falls on 6th(saturday) day of the week will add 2.
  • else add 1 for all other days of the week

Try this,

 last_day=20190426
 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input fall on 5th(Friday) day of the week will add 3.
  • if input fall on 6th(Saturday) day of the week will add 2.
  • else add 1 for all other days of the week
added 24 characters in body
Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88

Try this,

 last_day=20190426
 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input falls on 5th(friday) day of the week will add 3.
  • if input falls on 6th(saturday) day of the week will add 2.
  • else add 1 for all other days of the week

Try this,

 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input falls on 5th(friday) day of the week will add 3.
  • if input falls on 6th(saturday) day of the week will add 2.
  • else add 1 for all other days of the week

Try this,

 last_day=20190426
 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input falls on 5th(friday) day of the week will add 3.
  • if input falls on 6th(saturday) day of the week will add 2.
  • else add 1 for all other days of the week
added 212 characters in body
Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88

Try this,

 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input falls on 5th(friday) day of the week will add 3.
  • if input falls on 6th(saturday) day of the week will add 2.
  • else add 1 for all other days of the week

Try this,

 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

Try this,

 date -d "$last_day +$( if [ `date -d $last_day +%w` == 5 ]; then echo 3; elif [ `date -d $last_day +%w` == 6 ]; then echo 2; else echo 1; fi ) days" +"%Y%m%d"

The input may be of any day. so

  • if input falls on 5th(friday) day of the week will add 3.
  • if input falls on 6th(saturday) day of the week will add 2.
  • else add 1 for all other days of the week
Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88
Loading