duli
duli

Reputation: 1661

Why is awk saying that strings representing identical IP address are unequal?

Here is the sample output:

   $echo "0.0.0.0 : 0.0.0.0" | awk -F':' '{print $1==$2}' 
0

Why are the strings not equal? What do I need to do to make awk think

Upvotes: 1

Views: 54

Answers (1)

hek2mgl
hek2mgl

Reputation: 158150

This happens because you are using : as the delimiter. $1 will contain 0.0.0.0<space> and $2 will contain <space>0.0.0.0

You can specify a sequence of characters as delimiter:

... | awk -F' : ' '{print $1==$2}'

The above command is using the sequence: space colon space as delimiter.

Upvotes: 5

Related Questions