LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   awk in loop How to (https://www.linuxquestions.org/questions/linux-newbie-8/awk-in-loop-how-to-508645/)

Nkunzis 12-08-2006 02:20 PM

awk in loop How to
 
hi memeber
how can i use awk in a loop to get the columns of a table.such as


for count in ` cat file | awk '{ print $1 }' `

but i want to get another column
ın each loop

ıs it possible to do something like this

col=1

for count in ` cat file | awk '{ print $col }' `
do
--
-
--
let col=`expr col + 1 #get next column number
done

int0x80 12-08-2006 02:43 PM

Do I understand correctly that you want the xth column for the xth line? E.g. 1st column on the 1st line, 2nd column on the 2nd line, etc?

Nkunzis 12-09-2006 04:28 AM

awk column
 
to get xth column the xth has already been taken care of

int0x80 12-10-2006 01:34 PM

Perhaps try explaining what you are attempting to do? If you want every column from every row, you could use two for loops...
Code:

for each row;
    for each column;

...but I'm assuming you're doing something with the items? Otherwise why not just dump the original output?


All times are GMT -5. The time now is 08:47 PM.