getting a previous date in bash/unix getting a previous date in bash/unix shell shell

getting a previous date in bash/unix


try this:

date --date="yesterday" +%Y/%m/%d


dtd="2015-06-19"yesterday=$( date -d "${dtd} -1 days" +'%Y_%m_%d' )echo $yesterday;


you can use

date -d "30 days ago" +"%d/%m/%Y"

to get the date from 30 days ago, similarly you can replace 30 with x amount of days