I am a bit of a newbie with AWK, so woudl appreciate some help please.
I have a bash shell script, which has a variable that contains a string like this;
Field1 Field2 Field3 Field4 Field5
Let's say, the variable is called MYVAR.
I wnat to be able to use AWK to extract Field3 from MYVAR into a new variable.
I tried this;
Code:
NEWVAR=`awk '{print $3}' $MYVAR`
This doesn't seem to work, as it complains that it cannot open a file called Field1.
I was hoping this would use $MYVAR as the input stream for AWK, and then process the single line returning the 3rd element.
Looks like I have got something wrong somewhere.
The shell script is a BASH Script.
Can somebody help please?