I'm having trouble finding a way to print a specific column of a text file using the awk command.
I have the awk command within a FOR loop that is looping through a large number of directories and on each loop I utilize the awk command to print two columns from a text file containing a large number of columns. the first column I need stays the same through each looping process, so I'm able to use $1 without issue. The issue arises when I need to print a second column.
The second column I want printed by awk changes each iteration through the for loop. So far, What I have tried to do is this
#Simplified Example
count=1 # the counter starts at 1 because I will not be needing col 1
for i in $list; do
count=count+1
awk '{print $1 "\t" ${count}}' $file > ex_files.txt
done
Hopefully what I have written here makes sense. I've looked at may other help-pages to find what I'm doing wrong with my syntax but have been unsuccessful up to this point. Most examples where I have seen awk with a variable, it isn't a dynamic variable so I'm kind of stuck.
If there is a better command to do what I'm attempting to do as opposed to "awk", I'm open to that. please let me know if you need further clarification