I have the following output.txt
it consists only 2 columns to demonstrate:
Test1 Test1-IS-OK
Test2 Test2-IS-NOT
Test3 Test3-IS-OK
Test4 Test4-IS-OK
Test5 Test5-IS-NOT
Then my bash script has the following code:
#!/bin/bash
output="output.txt"
a=$(awk '{ print $1 }' $output)
b=$(awk '{ print $2 }' $output)
while IFS=" " read -r $a $b
do
echo "LOG: $a and $b"
done < "$output"
I got the following error:
./test.sh: line 13: read: `Test1-IS-OK': not a valid identifier
I need to have output like this
LOG: Test1 and Test1-IS-OK
LOG: Test2 and Test2-IS-NOT
LOG: Test3 and Test3-IS-OK
LOG: Test4 and Test4-IS-OK
LOG: Test5 and Test5-IS-NOT
But the code is not working. What is the best method to loop this 2 columns from a file? Is there a simpler method?