The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date Format biju.mp UNIX for Dummies Questions & Answers 2 12-31-2007 06:56 AM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 05:42 PM
Date format Knotty UNIX for Dummies Questions & Answers 2 04-11-2007 10:48 AM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 08:30 PM
date format big123456 Shell Programming and Scripting 2 07-22-2005 01:57 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-24-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
date format

i have a date format like this for example

24JAN2008

a=`date+"%d%b%Y"`--------this gives me date format 24Jan2008.

i want Jan and not JAN and likewise...this is just an example.....likewise there are so many months in caps .......

help me in this
Reply With Quote
Forum Sponsor
  #2  
Old 01-24-2008
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 99
date | tr "[:upper:]" "[:lower:]" will give all the value in lowercase.

for ur case...

echo 24JAN2008 | tr "[:upper:]" "[:lower:]" will gice the output as 24jan2008
Reply With Quote
  #3  
Old 01-25-2008
Registered User
 

Join Date: Apr 2007
Location: Kolkata
Posts: 81
Thumbs up date format

Dear ali560045,
if you dont mind can you please explain ur problem little bit clearely? it will be easier to give you a proper solution.
Thanks,
Regards,
Pankaj
Reply With Quote
  #4  
Old 01-25-2008
Registered User
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
Code:
date1=28JAN2008
date2=$(echo $date1 | sed 's/'$(echo $date1 | cut -c4-5)'/'$(echo $date1 | cut -c4-5 | tr '[:upper:]' '[:lower:]')'/')

echo date1=$date1
echo date2=$date2
Result:
Code:
date1=28JAN2008
date2=28Jan2008
Hope it'll help
Reply With Quote
  #5  
Old 01-25-2008
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
Using sed

Code:
echo $date | sed '
h
s/[0-9]\{1,2\}.\(..\).*/\1/
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
G
s/\(.*\)\n\([0-9]\{1,2\}.\)\(..\)\(.*\)/\2\1\4/
'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0