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
yesterday date month/date skully Shell Programming and Scripting 5 06-24-2008 05:51 AM
last month end date vanathi UNIX for Advanced & Expert Users 7 03-21-2008 04:17 PM
Append 0 for single digit entered from command line namishtiwari UNIX for Dummies Questions & Answers 2 08-24-2007 05:01 AM
how to get month last date in unix rajan_ka1 Shell Programming and Scripting 12 10-04-2005 07:20 AM

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

Join Date: Sep 2007
Posts: 70
single digit for day and month on date

hi all,
how do i format the date command so it displays day and month in single digits i.e 8 instead of 08 ??

am using the command (in a ksh) : date +%D
output i get is 10/08/08


thanks in advance.
  #2 (permalink)  
Old 10-07-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
date +"%Oe"
this will display date in single digit.. you wnat month too in single digit??
  #3 (permalink)  
Old 10-07-2008
cesarNZ cesarNZ is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 70
oh yes please
  #4 (permalink)  
Old 10-07-2008
cesarNZ cesarNZ is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 70
date +"%Oe" output has a space in it e.g " 8" is there a way to get rid of that space ??
  #5 (permalink)  
Old 10-08-2008
RahulJoshi's Avatar
RahulJoshi RahulJoshi is offline
Registered User
  
 

Join Date: Aug 2008
Location: PUNE
Posts: 98
as alreay mention by above user u can use for get rid of space
date +"%Oe"| sed 's/ //'
  #6 (permalink)  
Old 10-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Then why don't you simply change any occurrence of /0 to just /

Code:
date +%D | sed 's%/0%/%g'
However, the manual page indicates that you can disable padding by putting a hyphen before the format code.

Code:
date +%Y/%-m/%d

Last edited by era; 10-08-2008 at 02:05 AM.. Reason: %-m/%-d
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 10:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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