the following program needs to print the words
First
Second
Third
But because i parameter from awk not get the value from “for” loop its print all words:
First second third
First second third
First second third
How to fix awk in order to print first the “first” word second the “second” word and so on
THX
Yael
program:
for i in 1 2 3
do
echo "first second third" | awk '{print $i}'
done
You can change you code like this:
To use the variable ‘i’ from the shell.
You can also just change the record separator (RS) to have the same result :
But I’m not sure if that’s what you’re looking for.