#!/usr/local/bin/gawk -f `
{
awkvar2="/id=22/";
awkvar3="/end/";
if ($0 ~ awkvar2) {
triggered=1;
}
if (triggered) {
print;
if ($0 ~ awkvar3) {
triggered=0;
print "\n-----------------------------------------------\n"
}
}
}
this awk script is not working for me
i am trying to search from one line to another i.e id=22
till end
(the reason i am not using /<string>/,/<string>/
is because i want a big line after each block of search)
and i want this using variables only.
i could directly use the patterns if ($0 ~ /end/) {
but i dont want to do that, i want to use the variables inside the search pattern
(reason is i will be getting the values in the variables dynamically thorough the shell)
please advise me how to use variables inside the search pattern for awk
thanks...