我如何过滤掉包含canvasbench
和tracing_mark_write
的行,如下面的句子所示?
canvasbench-16333 [003] ...1 87432.398788: tracing_mark_write: B|16333|performTraversals\n\
There is no AND operator in grep. But, you can simulate AND using grep -E option.
grep -E 'canvasbench.*tracing_mark_write|tracing_mark_write.*canvasbench' filename
And alternatively, you can use multiple grep command separated by pipe to simulate AND.
grep -E 'canvasbench' filename | grep -E 'tracing_mark_write'
Alternatively you can use sed:
sed -n '/canvasbench/{/tracing_mark_write/p}' input
which tries to match tracing_mark_write on lines matching canvasbench and prints lines matching both.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.