Search This Blog

Showing posts with label patterns. Show all posts
Showing posts with label patterns. Show all posts

Wednesday, May 16, 2007

awk

Using shell variables with awk.

1. awk "/$func/"'{print $0}' filename

2. awk -v pat=$func '/pat/{print $0}' filename

Using fields in search pattern

For a similar match:

1. awk '$1~/pattern/{print $0}' filename

For a precise match:

2.  awk -F":" -v user=$U '$1 == user {print $0}' filename