如何从今年的日期格式提取并找到所有年大于 [英] How to extract year from date format and find all years greater than

查看:180
本文介绍了如何从今年的日期格式提取并找到所有年大于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打印所有年份1900更大的字段。我已经习惯了awk来获得字段的日期。但我无法弄清楚如何使用awk来拉动只有几年中,> = 1900。

到目前为止,我通过输入以下拉到这个领域:

awk的-F',''{打印$ 5}'presidents.csv

这给了我这些日子

  1893年4月3日
1897年4月3日
14/9/1901
1909年4月3日
1913年4月3日
1921年4月3日
1923年2月8日
1929年4月3日
1933年4月3日
1945年12月4日
20/01/1953
20/01/1961
22/11/1963
20/1/1969
1974年9月8日
20/01/1977
20/01/1981
20/01/1989
20/01/1993
20/01/2001
20/01/2009
现任


解决方案

 的awk -F',''{打印$ 5}'presidents.csv | awk的-F'/''$ 3 GT; 1900 {打印$ 1/$ 2/$ 3}

I need to print all years greater than 1900 in a field. I have used to awk to get the field with the date. But I can not figure out how to use awk to pull only the years that are >=1900.

So far I pulled this field by entering this:

awk -F',' '{print $5}' presidents.csv

this gives me these dates

4/03/1893
4/03/1897
14/9/1901
4/3/1909
4/03/1913
4/03/1921
2/8/1923
4/03/1929
4/03/1933
12/4/1945
20/01/1953
20/01/1961
22/11/1963
20/1/1969
9/8/1974
20/01/1977
20/01/1981
20/01/1989
20/01/1993
20/01/2001
20/01/2009
Incumbent

解决方案

   awk -F',' '{print $5}' presidents.csv | awk -F '/'  '$3 > 1900 { print $1"/"$2"/"$3 }'

这篇关于如何从今年的日期格式提取并找到所有年大于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆