按照给定的每小时间隔范围从邮件列表生成文本文件

按照给定的每小时间隔范围从邮件列表生成文本文件

这是一系列电子邮件文件,输出自$ ls --time-style=long-iso -la

23:12 1570840157.M399816P376041.br472.hostgator.com.br,S=300488,W=304621:2,
23:41 1570840228.M85932P379995.br472.hostgator.com.br,S=307582,W=311813:2,
00:31 1570840312.M211863P379995.br472.hostgator.com.br,S=301166,W=305309:2,
01:32 1570840376.M535629P379995.br472.hostgator.com.br,S=308153,W=312391:2,
02:34 1570840441.M68421P382468.br472.hostgator.com.br,S=307387,W=311615:2,
02:35 1570840530.M391347P385138.br472.hostgator.com.br,S=298927,W=303039:2,
04:06 1570840597.M688174P387663.br472.hostgator.com.br,S=302107,W=306263:2,
04:08 1570840657.M991954P387663.br472.hostgator.com.br,S=299284,W=303401:2,
04:09 1570840743.M587693P390982.br472.hostgator.com.br,S=299941,W=304067:2,
06:40 1570840805.M471644P390982.br472.hostgator.com.br,S=305586,W=309789:2,
06:44 1570840869.M734632P390982.br472.hostgator.com.br,S=302585,W=306747:2,
07:20 1570840929.M49892P396393.br472.hostgator.com.br,S=300967,W=305107:2,
08:10 1570840996.M935135P396393.br472.hostgator.com.br,S=309171,W=313423:2,

我们需要一个文本文件,其文件名和时间戳范围为 00:00 到 06:59。

知道如何做到吗?

答案1

awk -F':' '($1+0<7){ print }' file

用作:输入字段分隔符,通过添加零 ( $1+0) 将第一个字段转换为数字,如果值为 则打印该行<7

答案2

如果我理解正确的话,这对你有帮助吗?

grep "^0[0-6]:[0-5][0-9]" file > new_file

答案3

刚刚设法如何做到这一点,如下:

egrep "00:[0-5][0-9]|01:[0-5][0-9]|02:[0-5][0-9]|03:[0-5][0-9]|04:[0-5][0-9]|05:[0-5][0-9]|06:[0-5][0-9]" logfile00.txt > logfile01.txt

相关内容