I have thousands of lines that look like this:e0f186cf-c34d-42e9-b8a9-9b9cf1f304e7,TotalNumberOfHandledConnectionsOrSessions,TotalNumbe1211008586,1457343000,179.00The column before last is a timestamp. The issue is that it's in seconds, where I need it in milliseconds.So I'd like to right pad that number with 000.BUT - it's possible one day the lines will have the milliseconds in them, so shouldn't add 000 in that case.I tried using a few examples on this site with sed but none worked.
Using sed to pad-right a number in a CSV
sed
sed 's/,\([0-9]\{10\}\),\([0-9]*\.[0-9]*\)$/,\1000,\2/'This matches a pattern of:comma,exactly 10 digits,comma,some number of digits,a period (escaped),some number of digits,the end of the lineand replaces it with:comma,the 10-digit number (backreferenced by \1), three zeroes, comma,the last field, backreferenced by \2.