Need help with following date conversion:

I have my dates as 08/02/2010 and I want to convert into 8/2/2010, incase date is 18/12/2010 I want to be same way.

Please guide me.

If you are using ksh93 you can use the print %T syntax to achieve what you want to do

$ date="08/02/2010"
$ print $date
08/02/2010
$ date=$(printf "%(%-m/%-d/%Y)T" "$date")
$ print $date
8/2/2010
$
date=08/02/2010

IFS=/ read d m y <<.
$date
.

date=$( printf "%d/%d/%d" "${d#0}" "${m#0}" "$y" )
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.