-1

I have a log file in which I have the HTTP status codes I want to skip all the lines with the value as - in column 3.

Since - is a special character I am unable to match that using the == function on awk

1_column | 2_column | -
1_column | 2_column | 200
1_column | 2_column | 201

I want to skip the below line from being shown

1_column | 2_column | -

I am trying awk -F'|' '($3=='-')' but it doesn't work

Fix - I had to do awk -F'|' '($3==" - ")'

Danny
  • 135
  • 1
  • 7
  • 1
    This helped https://stackoverflow.com/questions/14739057/using-awk-with-column-value-conditions?rq=1 I had to do ```awk -F'|' '($3==" - ")'``` – Danny Nov 01 '22 at 07:28

1 Answers1

0

You could try

awk -F"|" '$3 !~ /-/ {print $0}' inputfile

The -F"|" will make | the column separator. and the entire line (print $0) will only appear if the 3rd column does not match "-"

F. Knorr
  • 3,045
  • 15
  • 22