Thursday, July 29, 2010

AWK - IF OR condition

OR operator : ||
AND operator: &&

awk -F, '{if ($1=="abc" || $1=="abd") print $0}' InputFile

-F,
InputFile is comma-separated (Field separator F is comma)

if ($1=="abc" || $1=="abd") print $0
Select and print entire record ($0) when first field ($1) is either "abc" or "abd"

No comments:

Post a Comment