Answers for "pass awk varible to bash"

2

bash how to pass shell variables to awk

# Example usage (one variable):
variable="one shell\nvariable"
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
Posted by: Guest on October-01-2020
0

pass awk varible to bash

x=10
y=30
text="some_texts"
awk -v a=$x -v b=$y -v c="$text" 'BEGIN {ans=a+b; print c " " ans}'
					#	for text it need " "
Posted by: Guest on May-26-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language