Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash how to pass shell variables to awk

# Example usage (one variable):
variable="one shell
variable"
awk -v var="$variable" 'BEGIN {print var}'
--> one shell
--> variable

# Example usage (multiple variables):
var1="multiple"
var2="shell"
var3="variables"
awk -v a="$var1" -v b="$var2" -v c="$var3" 'BEGIN {print a,b,c}'
--> multiple shell variables
Source by www.cyberciti.biz #
 
PREVIOUS NEXT
Tagged: #bash #pass #shell #variables #awk
ADD COMMENT
Topic
Name
7+3 =