1、
root@DESKTOP-1N42TVH:/home/test# ls a.txt root@DESKTOP-1N42TVH:/home/test# cat a.txt i A Em F d q ddd M d e N ffff i A Em F d q ddd M d e N ffff root@DESKTOP-1N42TVH:/home/test# for i in $(seq `head -n 1 a.txt | awk '{print NF}'`); do echo $i; done 1 2 3 4
2、
root@DESKTOP-1N42TVH:/home/test# ls a.txt root@DESKTOP-1N42TVH:/home/test# cat a.txt i A Em F d q ddd M d e N ffff i A Em F d q ddd M d e N ffff root@DESKTOP-1N42TVH:/home/test# for i in `head -n 1 a.txt | awk '{print NF}' | xargs seq`; do echo $i; done 1 2 3 4