1

I have next example of script:

The proposal is to find ID = 67109AB inside "file.txt", using an external variable, in this case, it's called: var. But, when I run script, it doesn't take value of variable like search pattern.

So, someone can help me to know if there is missing something?

Thanks for your help.

    fu="/67109AB/"
awk -v var="$fu" '
     var {
        print $0
}' file.txt
09stephenb
  • 9,358
  • 15
  • 53
  • 91

1 Answers1

0

I think you're looking for something like this:

fu="67109AB"; awk -v var="$fu" '$0 ~ var' file.txt
Steve
  • 51,466
  • 13
  • 89
  • 103