Unix,Oracle,Pl/SQL and more

Showing posts with label Date. Show all posts
Showing posts with label Date. Show all posts

Thursday, January 10, 2008

Convert Date format in Unix (ddmmyyyy to dd-mon-yyyy )

Could not find an inbuilt function in unix to convert ddmmyyyy to dd-mon-yyyy format.So wrote this script. Check this out.

month_mon='JAN+FEB+MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC'
time_stamp='01012007' #&1
dd=`echo $time_stamp (pipe) cut -c5-6`
mm=`echo $time_stamp (pipe) cut -c3-4`
yy=`echo $time_stamp (pipe) cut -c1-2`
file_mon=`echo ${month_mon} (pipe) cut -d"+" -f${mm}`
file_date=$file_dd'-'${file_mon}'-20'${file_yy}
echo $file_date


NOTE: The pipe symbol before cut is getting filtered out in this blog. Please take care to replace (pipe) with the actual one.

Blog Archive