-2

我有以下文本文件,并希望删除时间(第 4 个元素)不是 15 分钟的所有行。间隔。下面是一个文件示例:

224,2012,325,2029,1,0,0,0,0.458,8 224,2012,325,2030,1,0,0,0,0.458,9 224,2012,325,2031,1,0,0,0,0.458,9 224,2012,325,2032,1,0,0,0,0.458,9 224,2012,325,2033,1,0,0,0,0.459,8 224,2012,325,2034,1,0,0,0,0.458,8 224,2012,325,2035,1,0,0,0,0.458,8 224,2012,325,2036,1,0,0,0,0.459,8 224,2012,325,2037,1,0,0,0,0.459,9 224,2012,325,2038,1,0,0,0,0.459,8 224,2012,325,2039,1,0,0,0,0.458,9 224,2012,325,2040,1,0,0,0,0.458,9 224,2012,325,2041,1,0,0,0,0.459,9 224,2012,325,2042,1,0,0,0,0.459,9 224,2012,325,2043,1,0,0,0,0.459,9 224,2012,325,2044,1,0,0,0,0.459,8 224,2012,325,2045,1,0,0,0,0.459,8 224,2012,325,2046,1,0,0,0,0.457,8

与非十五分钟。删除更正文件的间隔应该是:

224,2012,325,2030,1,0,0,0,0.458,9 224,2012,325,2045,1,0,0,0,0.459,8

4

2 回答 2

0

由于您没有为我提供语言,因此我将为您提供用 Java 执行此操作的逻辑以帮助您。Java 不是一种脚本语言,但无论如何,它不会受到伤害:

假设s是一个字符串,它具有一行数据的值。

if (Integer.parseInt(s.split(",")[3].substring(2)) % 15 == 0) {
    //You have a row that satisfies your condition
}

如果条件满足,你可以为所欲为。

于 2013-08-13T18:18:33.500 回答
0

教科书示例:

awk -F, '!$4%15' filename
于 2013-08-13T18:19:08.183 回答