Skip to main content
2 of 4
added 212 characters in body
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
Siva
  • 9.3k
  • 9
  • 60
  • 88