N days ago

Hi,
the following gives today

$(date '+%d%m%y')

For example 210111 for today (21 of january 2011).
How can I have n days ego ? For example 160111 for 5 days ego ?

thank you.

perl '-MPOSIX qw(strftime)' -le'
  print strftime "%a %b %e %H:%M:%S %Y", 
    localtime time - 86400 * shift;
  ' <n>

For example:

% perl '-MPOSIX qw(strftime)' -le'
  print strftime "%d%m%y", localtime time - 86400 * shift;
  ' 5
160111

thank you but can I use this in a filename.sh to define a variable? how ?

MYVARIBLE=???

MYVARIBLE="$(
  perl '-MPOSIX qw(strftime)' -le'
    print strftime "%d%m%y", localtime time - 86400 * shift;
    ' 5
    )"