putting
schema_entries=$( awk -v var="$get_schema" -v var2="$cmd_arg" '$0 ~ var{ print $'var2' }'
at the bottom works but its hard to believe there isnt a command to reeval the variable without redefining it
arg well i still have one more problem while implementing this.... i cant get the shell to re-eval the variable.
i have 3 variables
get_schema=$( awk -v var="$1" '$0 ~ var{ print $2 }' databases.txt )
cmd_arg=2
schema_entries=$( awk -v var="$get_schema" -v var2="$cmd_arg" '$0 ~ var{ print...
Basically to give you an over view. the $my_awk script is something ill use ALOT in my script because it simply reads a file that has 2 columns. Column 1 is the database name. Column 2 is the schema file assosiated with it so now instead of rewritting that script everytime i need the schema file...
$my_awk is a variable script that is defined by the argument im trying to write
and you freaken brilliant. this little piece of code has been driving me crazy for about 2 days.
Ok next quest is can you explain maybe why you have to put it in the $(......) to get it to idetify the line of code...
#!/bin/sh
#Section: 04
#Name: Scott Deese
my_awk="awk -v var=$1 ' /$var/ { print \$2 } ' "
echo $my_awk
schemas=`$my_awk database.txt`
ive tried this many different ways and this was the last way describe by my teacher that doesnt work.
I need to pass a variable from the sh shell to awk. the...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.