我正在尝试使用awk中的条件,该条件用于过滤一行其所有字段都满足正则表达式条件的行,而不是逐一遍历这些字段。 例如,我想要其中仅包含(是或确定)的行
示例输入:
yes yes yes no no ok nok
no yes yes whatever
yes yes ok
ok yes
示例输出:
yes yes ok
ok yes
答案 0 :(得分:3)
取决于您的定界符,假设它是空格或制表符,那么您可以执行以下操作:
start_process.py
ps:import turtle
import random
class turtles:
def __init__(self):
turtle.Pen()
turtle.color(random.randint(0.0, 1.0),random.randint(0.0, 1.0) ,random.randint(0.0, 1.0))
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
while True:
t1= turtles()
是GNU awk的功能,对于其他版本,您可能需要将其更改为awk '$0~/^((yes|ok)\s+)*(yes|ok)$/{print}' file
。
\s
和[ \t]
部分实际上是隐式的,我们可以删除它们,只需使用以下命令即可:
$0~