When a pattern matching is done using ~ we need to give the reg-exp in between / / (2 forward slashes).Still, when given inside the slashes it is taken as literally, so when changing the above awk as
echo jon | awk -v xa=$x '$1~/xa/ {print}'
it matches the word xa and not the variable xa's value.Hence we need to expand the variable as below
x=/jon/
echo jon | awk -v xa=$x '$1~/'"$xa"'/ {print}'
This is not the case when == is used as you would know this is used to equate between variables.Therefore in code $1==xa.. xa is expanded (to jon).
Why are there two pairs of quotes? I would say that there is one pair of double quotes too many, but when I remove them, it produces an error (different, depending on which pair I remove).
P.S. The script is meant to be a calendar reminder. There is an additional text file. It contains something like the following text:
Sep 30 mother's birthday
Oct 1 lunch with joe, noon
Oct 1 meeting 4pm