Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有大量包含一天时间戳数据的文本文件。每个文件是一天。我想从一天中同一时间的每个文件中提取一行。以下工作但很慢 - 有更快的方法吗?
for f in nGENERIC*.txt ;do egrep -m1 "*T1600*" $f ; done > a
只是grep应该做...
grep
grep -m1 "T1600" nGENERIC*.txt > output
由于您并没有真正使用任何正则表达式,因此最好使用-Fswitch 来避免正则表达式处理并使其效率更高:
-F
grep -F -m1 "T1600" nGENERIC*.txt > a
你试过头吗?
for f in nGENERIC*.txt ;do head -n1 $f ; done > a