The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help, I need to get the last date of previous month sirrtuan Shell Programming and Scripting 11 10-14-2008 05:59 AM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 11:30 PM
Specify a previous date as start date in shell script ritzwan0 Shell Programming and Scripting 2 09-25-2006 05:58 PM
Get the Previous date Nayanajith Shell Programming and Scripting 2 06-29-2006 01:39 AM
How to find Previous date and Coming date arunava_maity UNIX for Dummies Questions & Answers 2 05-24-2001 11:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-22-2008
Prat007 Prat007 is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 20
How to get Previous date in this format.

hi ,

I am using this to get previous date :

#!/usr/bin/ksh
date '+%m %d %Y' |
{
read MONTH DAY YEAR
DAY=`expr "$DAY" - 1`
case "$DAY" in
0)
MONTH=`expr "$MONTH" - 1`
case "$MONTH" in
0)
MONTH=12
YEAR=`expr "$YEAR" - 1`
;;
esac
DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
esac
echo "Yesterday was: $MONTH $DAY $YEAR"
}
Output : 07 21 2008

i want output as Jul 21, not as 07 21, can someone help me out.

Thanks
  #2 (permalink)  
Old 07-22-2008
BMDan BMDan is offline
Registered User
  
 

Join Date: Jul 2008
Location: BlackMesh Managed Hosting
Posts: 66
How about:
Code:
$ date -d "yesterday" +"%b %d %Y"
Jul 21 2008

Last edited by BMDan; 07-23-2008 at 10:16 AM.. Reason: Misread which month encoding you wanted
  #3 (permalink)  
Old 07-22-2008
sudhamacs sudhamacs is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 98
YESTERDAY=`TZ=GMT+24 date "+%m %d %Y"`
  #4 (permalink)  
Old 07-22-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,861
If you are using ksh93
Code:
$ printf "%(%b %d)T\n" "yesterday"
Jul 21
$
  #5 (permalink)  
Old 07-23-2008
sujana sujana is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 5
TZ=GMT+24 date "+%b %d %Y"

Jul 22 2008
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0