pass variable to awk from outside
October 17th, 2006 mysurface Posted in awk, Bash, Text Manipulation | Hits: 22368 | 2 Comments »
Many people uses awk in their shell script, but they need to pass variable to awk for manipulation, it is not difficult, bellow is a simple example.
awk 'END { print myval }' myval=`pwd` data.txt
This example is to show you, I successfully pass a value from outside, at the END of the manipulation, print me my value I pass in. You can specified any variable name, for this case i uses “myval”.
If you define your awk rules in a file, you can do that as bellow to pass in variables.
awk -f bandwidth.awk measurement="kbps" proto="tcp" pcap.tr







September 14th, 2008 at 5:11 am
thanks.
August 13th, 2011 at 8:10 am
i had love to check out the video of the tire appearing rolled to your dwelling…