日期操纵AWK变量:非军用格式 [英] Date manipulation in awk variable : Non Military Format
本文介绍了日期操纵AWK变量:非军用格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在提到code: | AWK'{打印$ 1,$ 2}
AWK $ 2 着有周四11月19日17:00:00 2015年在里面。我想只有在非军用格式内嵌awk的有操纵这个日期字符串周四11月19日下午五点00分00秒2015年。请帮助。
In the mentioned code : | awk '{ print $1, $2 }'
AWK $2 is having "Thu Nov 19 17:00:00 2015" in it. I want to manipulate this date String there only in inline awk in Non Military format "Thu Nov 19 05:00:00 PM 2015". Please help.
推荐答案
这行应该给你预期的格式为:
This line should give you the expected format:
kent$ echo "Thu Nov 19 17:00:00 2015"|awk '{d=$0;cmd="date -d\""d"\" +\"%a %b %d %r %Y\"" ;cmd|getline $0;close(cmd)}7'
Thu Nov 19 05:00:00 PM 2015
在这里你去:
kent$ echo "FOO,Thu Nov 19 17:00:00 2015"|awk -F, '{d=$2;cmd="date -d\""d"\" +\"%a %b %d %r %Y\"" ;cmd|getline $2;close(cmd);print "col1:"$1 RS "col2:"$2}'
col1:FOO
col2:Thu Nov 19 05:00:00 PM 2015
这篇关于日期操纵AWK变量:非军用格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文