我几乎有需要的工作代码,只是我不太了解所有语法。 我为之前的无法理解的帖子表示歉意,因此我将重新编写请求,希望更容易理解。 我有一条数百行的消息日志。在此日志中,有两行与我提取数据有关。 日志中的两条日志行是:
2357: 11-Feb-2019 09:51:22 (low) [] 1369 floating point MIPS (Whetstone) per CPU
2358: 11-Feb-2019 09:51:22 (low) [] 5388 integer MIPS (Dhrystone) per CPU
我正在从这两行中提取值1369和5388。我创建的代码是:
proc=( $(boinccmd --get_messages | sed -n 's/\s*integer MIPS (Dhrystone) per CPU//p' | awk -F\ '{print $6}') )
printf "%s"${proc}"\n"
proc=( $(boinccmd --get_messages | sed -n 's/\s*floating point MIPS (Whetstone) per CPU//p' | awk -F\ '{print $6}') )
printf "%s"${proc}"\n"
但这会导致sed进行两次钓鱼。
有没有办法通过使用不同的过程或者通过sed double-up并同时查找两件事来使这一点更有效?
谢谢。
答案 0 :(得分:2)
awk怎么样:
$ awk '{print $6}' file
1369
5388
答案 1 :(得分:0)
如果选择Procedural Text Edit
:
forEach line {
ifElse (or
(contains cs "floating point MIPS (Whetstone) per CPU")
(contains cs "integer MIPS (Dhrystone) per CPU")) {
select (afterN char 4) { remove }
} {
remove
}
}