datetime - Converting dates in AWK -


I have a file that contains several columns of text, in which is Friday 02 January 18:23 at one Timestamp and I need to change that date to MM / DD / YYYY HH: MM format.

I use the standard 'date' tool to get the awk conversion gateline, but I can not understand how the field is to be presented in the format in 'date' command (this is " Or "has been quoted with), the lineline is also included in quotation marks.

Something like this "date -d '$ 1 $ 2 $ 3 $ 4' + '% D% H:% M'" | Getline var

Now when I think about it, I think exactly what I'm saying is how to embed awk variables in the string.

You can try it. You only have the file in the specified date

  awk '{cmd = "date" "+% m /% d /% y% h:% m \" -d \ "" $ 1 "" $ 2 "" $ 3 "" $ 4 "\ "CMD | Getliner Print Print Close Close (cmd)} 'File  

Output

  $ ./shell.sh 01/02/2010 18: 23  

And if you are not using GNU tools, as if you are in Solaris for example, use the nose

  nawk 'BEGIN {m = split ("Jan Feb | Mar | Apr | May | Jun | (Month [D]] = sprintf ("% 02d ", o) (o = 1; o July / August | September | Oct | Dec | Dec | Dec ", D," | ")} CMD =" Date +% Y "CMD | Milling UR Off (CMD)} {day for t ==; = $ 3 months = months [$ 2] print mahindra "/" day "/" yr "" $ 4} 'file  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -