Date format MM/DD/YYYY
required is YYYYMMDD, I tried using sed but could not get it any help please.
awk '{print substr($0,7,4) substr($0,1,2) substr($0,4,2)}'
or
awk 'BEGIN {FS="/"; OFS=""} {print $3,$1,$2}'
try:
#!/bin/ksh
reformat()
{
echo "$1" | tr -s '/' ' ' | read month day year
echo "$year""$month""$day"
}
for dt in 01/10/1999 10/01/2000 12/30/2006
do
echo "$(reformat "$dt" )"
done
that worked Thanks
$ echo MM/DD/YYYY | sed -e 's_^\(.\{2\}\)\/\(.\{2\}\)\/\(.\{4\}\)$_\3\1\2_'
YYYYMMDD