Unix/Linux Go Back    



Keeping padding in a date field

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member seanbyrne Regarding:
Keeping padding in a date field.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 01-09-2009
seanbyrne seanbyrne is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 16 January 2009, 10:13 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Keeping padding in a date field

Hi Guys,

I'm having a bit of a problem with a script, i need to get the day, month and day of month into a string, so i'm using:


Code:
CURRENT_DATE=`date +"%a %b %e"`

It is getting the correct date out, however it is not keeping the padding on the day of month. The %e is supposed to pad the day of month, but it doesn't seem to want to.

What should be coming out is 'Fri Jan 9' (2 spaces padding before the 9), but it is giving me 'Fri Jan 9' (one space Linux)

If i use the command 'date' in the unix shell it brings it in the right format, however if i use 'echo `date`' it removes the padding on the day of the month.

This is probably a very confusing post, i apologise!! Really hope someone can help Linux