I’m trying to write a BASH script that will append :00:00 to the end of all values in the 2nd field of a CSV file.
I’ve tried reading through ‘awk’ man pages but I’m not understanding how I can complete this. Any help is appreciated!
Source file:
2012-02-29,00,Manhatten,New York,244
2012-02-29,01,Manhatten,New York,246
2012-02-29,02,Manhatten,New York,554
2012-02-29,03,Manhatten,New York,854
2012-02-29,04,Manhatten,New York,488
Result file:
2012-02-29,00:00:00,Manhatten,New York,244
2012-02-29,01:00:00,Manhatten,New York,246
2012-02-29,02:00:00,Manhatten,New York,554
2012-02-29,03:00:00,Manhatten,New York,854
2012-02-29,04:00:00,Manhatten,New York,488
Below is a command to filter the conversion:
If you have a file
source.txtwhich store source data and a fileresult.txtto be stored the output, following command will do:If you have multiple input files, you can add them in arguments.
See manpage of awk for more details.