sed - How to match date mm/dd/yyyy -
given following input
506028500,1820196768,43,0,84552257, ,1,-71.16,42.42,04/26/2012, i want filter date @ end of row, can change mm/dd/yyyy format mysql date format yyyy-mm-dd:
i trying match date @ end of row having first removed trailing ',' (comma).
{ s/,$//g /\([0-9][0-9]\)\/\([0-9][0-9]\)\/\([0-9][0-9][0-9][0-9]\)$/= } i'm getting 12847, expecting 04262012.
what doing wrong, can't match date that's there?
thanks.
this might work you:
echo "506028500,1820196768,43,0,84552257, ,1,-71.16,42.42,04/26/2012," | sed 's|,\(..\)/\(..\)/\(....\),$|,\3-\2-\1,|' 506028500,1820196768,43,0,84552257, ,1,-71.16,42.42,2012-26-04, if want date:
echo "506028500,1820196768,43,0,84552257, ,1,-71.16,42.42,04/26/2012," | sed 's|.*,\(..\)/\(..\)/\(....\),$|\3-\2-\1|' 2012-26-04
Comments
Post a Comment