Attila Bukta, PhD
Home > Linux > Using Shell Variables with AWK

Using Shell Variables with AWK

Pattern matching example:

1
awk '/foo1/ && /foo2/ { print $1 }'

To use shell variables simply do the following:

1
2
3
4
foo1={pattern1}
foo2={pattern2}
 
awk "/$foo1/ && /$foo2/"'{ print $1 }'
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.