Get Yesterday's date in solaris
Try this below thing. It should work
YESTERDAY=`TZ=GMT+24 date +%Y%m%d`; echo $YESTERDAY
In a unix shell, how to get yesterday's date into a variable?
If you have Perl available (and your date
doesn't have nice features like yesterday
), you can use:
pax> date
Thu Aug 18 19:29:49 XYZ 2010
pax> dt=$(perl -e 'use POSIX;print strftime "%d/%m/%Y%",localtime time-86400;')
pax> echo $dt
17/08/2010
How to get yesterday date in Unix
Ksh
's printf
supports datetime manipulation:
# echo ${.sh.version}
Version AJM 93u+ 2012-08-01
# printf '%(%Y-%m-%d)T\n' today
2015-09-03
# printf '%(%Y-%m-%d)T\n' yesterday
2015-09-02
# printf '%(%Y-%m-%d)T\n' '5 days ago'
2015-08-29
#
Get yesterday's date in bash on Linux, DST-safe
I think this should work, irrespective of how often and when you run it ...
date -d "yesterday 13:00" '+%Y-%m-%d'
getting a previous date in bash/unix
Several solutions suggested here assume GNU coreutils
being present on the system. The following should work on Solaris:
TZ=GMT+24 date +’%Y/%m/%d’
Related Topics
How to Read Config Files with Section in Bash Shell
Process Stuck in Exit, Shows as Zombie But Cannot Be Reaped
Sending Keycode to Xorg + Wine with Bash Script
How to Capitalize First Letter of Each Line in Bash
Why Does This Movq Instruction Work on Linux and Not Osx
Linux /Bin/Sh Check If String Contains X
How to Install Visual Studio 2015 in Ubuntu
How to Find List of Odbc Drivers Installed on Linux
Dlopen Failed: Cannot Open Shared Object File: No Such File or Directory
How to Make the Watch Command Interpret Vt100 Sequences
Possibly Undefined MACro: Ac_Prog_Libtool
What Does the "Mov Rax, Qword Ptr Fs:0X28" Assembly Instruction Do
What Does the Line '!/Bin/Sh -E' Do
Changing Color of Eclipse Links in Quick Fix or Eclipse Links in Preferences on Linux
Visual Studio Code Debugger Error:"Could Not Find the Task 'Gcc Build Active File'