Columns Built in awk Variables don't export

Print Friendly

By newbie2010

I need to export the built in awk variables for columns so that they are available for the rest of the script. This is what I have so far:


cat /tmp/test | eval `awk '{print "export NAME="$1; print "export NAME2="$2;}'`
echo Host is "$NAME" and Host2 is "$NAME2"


When I run bash -x to debug, the variables do get assigned but then when the echo command runs they come up empty. I need to have these variables assigned so that the entire script can make use of them. Any ideas would be greatly appreciated.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

FavoriteLoadingAdd to favorites

Leave a Reply

Your email address will not be published. Required fields are marked *