Can any one guie me how to find yesterday's date (taking care of the leap years as well)in the format yymmdd using a shell script.
Regards.
programmer321
0
Light Poster
Recommended Answers
Jump to PostThe gnu version of the "date" command (as used in linux/cygwin) has this functionality built in already.
If you are using linux you can simply use
date --date=yesterday +%y%m%d
See man date for more details.
Jump to PostHey there,
If you're interested, just for kicks, here's the long convoluted way to do it :)
http://linuxshellaccount.blogspot.com/2008/01/unix-and-linux-shell-script-to-remind.html
Cheers,
Mike
Jump to PostIf you are using ksh93 (Korn Shell 93) , date manipulation is builtin, i.e.
$ printf "%(%y%m%d)T\n" yesterday 100318 $
Jump to Post#! /bin/bash ######## Created By - R.Wesley Dev Andrew ######### date=`date +%d-%m-%Y` #echo "Please input date in format dd-mm-yyyy" #read date day=`echo $date | awk -F\- '{print $1}'` month=`echo $date | awk -F\- '{print $2}'` year=`echo $date | awk -F\- '{print $3}'`
There no need for …
All 14 Replies
blater
2
Light Poster
programmer321
0
Light Poster
eggi
92
Posting Whiz
dev_272000
0
Newbie Poster
fpmurphy
9
Junior Poster
issue9
0
Newbie Poster
issue9
0
Newbie Poster
cfajohnson
7
Shell scripter and author
dev_272000
commented:
Great link
+0
dev_272000
0
Newbie Poster
ethi
0
Newbie Poster
dev_272000
0
Newbie Poster
cfajohnson
7
Shell scripter and author
kevinkatia
0
Newbie Poster
cfajohnson
7
Shell scripter and author
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.