Neethu Lalitha
Neethu Lalitha

Reputation: 3071

Unix awk Substring string comparison

I want to find if a substring is contained in a string using Unix AWK command.

eg, pseudocode:

a= commandline
b=line
if(b is contained in a)
  print "success " 

Upvotes: 1

Views: 253

Answers (1)

Gilles Quénot
Gilles Quénot

Reputation: 185530

$ awk 'BEGIN{a="commandline";b="line";if (a ~ b){print "success"}}'
success

Upvotes: 3

Related Questions