Article 520ZF BASH - variable as variable

BASH - variable as variable

by
carlolab
from LinuxQuestions.org on (#520ZF)
Hi,

I have a "fileX" test file with a content like this:

a b c d e f

I need to make a for cicle to print column 2 to 6

for col in {2..6}
do
cat fileX | awk '{ print $$col }'
done

The problem is to pass variable $col as variable in print function of awk.
The part '{ print $$col }' shold be read as '{ print $2 }' then '{ print $3 }' etc.etc.

Can someone help me?

Thank You

Carlolatest?d=yIl2AUoC8zA latest?i=MBFQZ0pHKFg:TO58wnYcr40:F7zBnMy latest?i=MBFQZ0pHKFg:TO58wnYcr40:V_sGLiP latest?d=qj6IDK7rITs latest?i=MBFQZ0pHKFg:TO58wnYcr40:gIN9vFwMBFQZ0pHKFg
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments