Print lines according to their columns in shell scripts

I know this is a very simple question, but im total new in shell scripts

i txt file called "berkay" and its contents are similar to

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

I want to print rows whose second column is an error, so the output will be

03:05:18 blablablablabla2 error

I think of something like "if nawk {$ 2}", but I need help.

+3
source share
1 answer

Using this, for example:

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

Why does this work? Because when the condition is true, awkautomatically performs its default behavior: {print $0}. Therefore, there is no need to explicitly write it.

+3
source

All Articles