3

i know it is very basic question but im total new in shell scripting

i a txt file called 'berkay' and content of it is like

03:05:16 debug blablabla1
03:05:18 error blablablablabla2
05:42:14 degub blabblablablabal
06:21:24 debug balbalbal1

I want to print the lines whose second column is error so the output will be

03:05:18 error blablablablabla2

I am thinking about something like " if nawk { $2}" but i need help.

4

1 回答 1

3

以此为例:

$ awk '$2=="error"' file
03:05:18 error blablablablabla2

为什么这行得通?因为当条件为真时,awk会自动执行其默认行为:{print $0}. 所以没有必要明确写出来。

于 2014-02-11T13:06:28.690 回答