Passing argument to awk

Thanks Peter, that stackoverflow.com topic is very helpful.
Here's an example Macro that uses that technique:

Example Output

image

MACRO:   Using KM Variables with Bash awk [Example]

~~~ VER: 1.0    2019-11-25 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Using KM Variables with Bash awk [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


Shell Script

echo | awk -v env_var="$KMVAR_My_KM_Variable" '{print "The value of My_KM_Variable is: \""env_var"\""}'
1 Like