awk date convert

awk '{cmd="date --date=\""$1"\" +\"%Y/%m/%d %H:%M:%S\" "; cmd | getline convdate; print cmd";"convdate }' file.txt
Convert readable date/time with `date` command
Sample Output
date --date="Mon Feb 27 12:06:58 2012" +"%Y/%m/%d %H:%M:%S";2012/02/27 12:06:58
date --date="Mon Feb 27 12:11:15 2012" +"%Y/%m/%d %H:%M:%S";2012/02/27 12:11:15
date --date="Mon Feb 27 12:12:47 2012" +"%Y/%m/%d %H:%M:%S";2012/02/27 12:12:47

1
By: EBAH
2012-02-28 14:08:52

What Others Think

This command converts the field in date correctly. Is there any way to print record iff the converted date "cmd" is before sysdate?
amitpyd · 276 weeks and 3 days ago
It is ideal if the illuminating toy that is picked plays music, regardless of whether that it isn't the fundamental purpose behind party of the toy. Check this http://www.colonchecker.com/">homepage to get more info. A melodic toy won't just be fun and attracting for a youthful grown-up to play with, it would show them a ton.
Ahmed74 · 3 weeks and 6 days ago
Other than appearing for three hours dependably, I am moreover drinking Chocolate milk constantly. This source homepage also help in the achievement of your goals. Drinking this is encouraging me particularly in fulfilling my success targets.
Ahmed74 · 3 weeks and 6 days ago
I am for each situation more empowered by the cross variety sort base plans since they are ordinarily expected to cover every single something. Visit homepage for more details. In any case, growing quite a base takes a lot of time.
Ahmed74 · 3 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: