Hi Guys,
I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need.
I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles.
#set 2 variables below
JOBNAME=abc_def
AUTO=A12
#Below line creates a variable using comma as a field separator
DESC=`/bin/awk -F',' "/^$JOBNAME/"
/apps/test/scripts/library/desc.output.$AUTO`
Content of /apps/test/scripts/library/desc.output.A12
abc_def,GHIJKLABCEQAVTCRIT AMM Clean Applogs
I am expecting $DESC variable to be the line in that file so my next variable I can print i.e.
DESC1=`echo $DESC | awk -F',' '{print $2}'` ;
TAGID=`echo $DESC1 | awk -F' ' '{print $1}'` ;
The problem is that although this works from the command line it doesn't in my ksh script. It doesn't assign anything to $DESC, presumably because it can't expand the JOBNAME and AUTO variables.
Can anyone please advise if this is just a quoting issue and if so - what syntax should work?
Thanks,
Gary