Hi,
I need to convert the below string in 'yyyymmdd' format.
e.g.,
24 June 2011 -> 20110624
Please help !!
Hi,
I need to convert the below string in 'yyyymmdd' format.
e.g.,
24 June 2011 -> 20110624
Please help !!
GNU date:
% date -d'24 June 2011' +%Y%m%d
20110624
in my machine , date -d option is not available
use the below line to convert and it applies for other months also.
echo "24 June 2011" | awk ' { if ( $2~/June/ ) { print $3"06"$1 } } '
this command will work for any date and any month
bash-3.00$ echo "24 June 2011" | nawk ' { months=" JanFebMarAprMayJunJulAugSepOctNovDec";date=$1;month=index(months,substr($2,1,3))/3;year=$3; printf("%s%02s%02s\n",year,month,date)}'
20110624
bash-3.00$ echo "10 June 2011" | nawk ' { months=" JanFebMarAprMayJunJulAugSepOctNovDec";date=$1;month=index(months,substr($2,1,3))/3;year=$3; printf("%s%02s%02s\n",year,month,date)}'
20110610
bash-3.00$ echo "1 November 2011" | nawk ' { months=" JanFebMarAprMayJunJulAugSepOctNovDec";date=$1;month=index(months,substr($2,1,3))/3;year=$3; printf("%
s%02s%02s\n",year,month,date)}'
20111101
A good throw kamaraj.. Really good ..