the content of a.txt
name age
alice 21
ryan 30
#test.sh
nf=`awk '{print NF; exit}' a.txt`
for((i=1;i<=$nf;i++))
{
awk '{print $i}' ./a.txt
}
The result I expected is print per column,but the actual result is print all content twice.
my expected output is
name
alice
ryan
age
21
30
actual output is
name age
alice 21
ryan 30
name age
alice 21
ryan 30