awk '{print$2}' $x
In this statement, awk try to print the second field of every lines of the file $x.
If you want that awk works on the contents of the variable, tou must write :
echo $x | awk '{print $2}'
In fact the result will be empty and not the field2 of the original file, since you concatenate fields 1 and 2.
If tst contains 'aaaa bbbb ccc'
x will contains "aaaabbbb" which is single field.
What do you want to do exactly ?
If you need fields 1 and 2, you can do :
Code:
while read field1 field2 other_fields
do
echo "Field 1: $field1"
echo "Field 2: $field2"
donei < tst