[awk] using shell variable
Posted on July 15, 2013, 1:07 PM
Shell variable can be ported into awk command by using "-v" flag:
#!/bin/bash var=100 awk -v var=$var '{print $1*var}' file.dat |
If there are more than one shell variable to call, use -v again and put space in between:
awk -v var=$var -v var2=$var2 '{print $1*var, var2}' file.dat |