Piping a bash variable into awk and storing the output
- by Andrew Smith
Hello,
To illustrate my problem,
TEST="Hi my name is John"
OUTP=`echo $TEST | awk '{print $3}'`
echo $OUTP
What I would expect this to do is pass the $TEST variable into awk and store the 3rd word into $OUTP.
Instead I get "Hi: not found", as if it is expecting the input to be a file. If I pass just a string instead of a variable, however, there is no problem. What would be the best way to approach this?
Thanks all!