Can we use shell variables in awk?

Yes, you can use the shell variables inside awk. There are a bunch of ways of doing it, but my favorite is to define a variable with the -v flag: $ echo | awk -v my_var=4 ‘{print “My var is ” my_var}’ My var is 4 Just pass the environment variable as a parameter to … Read more