grep的/ awk的比大于日期 [英] Grep / awk greater than date
问题描述
我敢肯定,这是一个容易的大师。我正在做我的事情和待办事项系统。
此刻我简直是我在VI编辑和设置标签对我的事情做了降价文件。
I'm sure this is an easy one for the Gurus. I'm working on my get things done and todo system. At the moment I've simply got a markdown file which I edit in VI and set tags against my things to do.
它看起来像这样
# My project | @home
- Do this this | @home
我觉得这个同步文件在我的设备和使用塔斯克/ grep的Android上向我展示基于我在哪里待办事项。
I think sync this file across my devices and use tasker / grep on android to show me the todo based on where I am.
现在我得在这里我想补充的东西在将来这样做我喜欢
I've now got to the stage where I want to add things to do in the future so I was thinking of something like
- Do this thing in the future | @home @2014-02-01
我怎么能排除这条线,直到日期是2014年2月1日?
我现在命令只提取@Home待办事项是
How could I exclude that line until the date is 2014-02-01? My current command for just extract @home todos is
grep -e "@home" myfile | cut -d '|' -f1
我相信有这样的一种方式,但谷歌/计算器并没有导致我朝着正确的方向呢!
I'm convinced there's a way of doing this, but google / stackoverflow hasn't lead me the right direction yet!
帮助AP preciated,
Help appreciated,
感谢
阿伦
推荐答案
用awk:
DAT=$(date +%Y%m%d) # get today's date, for example 20140117
awk 'NF>3{gsub(/-/,"",$NF);if ($NF>d) next}{print $1}' FS="[|@]" d=$DAT file
# My project
- Do this this
这篇关于grep的/ awk的比大于日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!