Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Need to change date format in a csv file using awk

$
0
0
Example:
Input csv file
Code:

00245DLS,Sitel Ocala,12/31/2014,18:45,1.00,7.00,0.00,0.00
00245DLS,Sitel Ocala,12/31/2014,19:00,-1.00,-1.00,-1.00,-1.00
00245HB,Charlotte,01/01/2015,00:00,-1.00,-1.00,-1.00,0.00

Output csv file
Code:

00245DLS,Sitel Ocala,2014/12/31,18:45,1.00,7.00,0.00,0.00
00245DLS,Sitel Ocala,2014/12/31,19:00,-1.00,-1.00,-1.00,-1.00
00245HB,Charlotte,2015/01/01,00:00,-1.00,-1.00,-1.00,0.00

i was able to do it as different field using this
Code:

cut -d',' -f3 test_tgt.csv | awk -F"/" '{ print $3"/"$1"/"$2 }'
Result:
Code:

2014/12/31
2014/12/31
2015/01/01

Please help..!!!

Viewing all articles
Browse latest Browse all 16232

Trending Articles