Awk Utilities

Hi,
My input file is like this
1 11110001 1.1.1.1.1
2 12222212 2.3.44.5.6
3 22223333 1.3.2.4.1.55

Now i need the 2nd column value get printed
I tried with the following command
awk 'NR==1 {print $2}' input

this works fine for only 1st row.I need to change always NR assigned value to get printed all the 2nd column values so i tried like this but i m not getting

for( i=1;i<=3;i++)
do
Index=`awk 'NR==$i print $2}' input`
echo $Index

But i am not getting any value printed

It works fine for me to do
awk '{print $2}' filename

Thanks for ur help but I actually need 1st row's 2nd column value.Like in the input file i need only 11110001 to be printed ,then after 1 iteration it should print 2nd row 2nd column value then 3rd row 2nd column value

I'm not shure if I understand your question, but the command I gave you will give you this output:

11110001
12222212
22223333

Is'nt this what you are trying? Else show the output you want.

see
Index=`awk 'NR==1 print $2}' input`
value=Index+3000

so the output will be 11113001
Like this it has to use for all the rows one by one

similar to this
for(i=1;i<=3;i++)
do
Index=`awk 'NR==$i print $2}' input`
value=Index+3000
echo $value
done

If the value 3000 remains same for all the iterations then

awk '{ print $2+3000 }' file

Actually i need the value of 1st row and 2nd column once i.e 11110001 and do a set of operations on that value .I gave just example of adding 3000 but i have set of operations using that value.Then after all operations done it has iterate by itself and give the 2nd row 2nd column value to perform the set of operations .Then the 3rd row 3rd column...please give me the suggestion on how to capture one by one

How abt this

awk -F" "  'NR==1 { print $2+1000} NR==2 { print $2+2000} NR==3 { print $2+3000}' file

In the actions...u may cary out your set of operations....
I have just considered a sample eg..

Thanks ..
but i have lot of operations ...i cant put all of them in one command line ...thats why i am trying to put in for loop....Do u have any suggestions to use awk in loop

Awk itself iterates over the file....so no need to loop through each of the lines...

About the set of operations...There is no restriction on no.of commands...

refer below...some more set of operations...on NR==1

awk -F" "  'NR==1{val=$2;print val + 1000, val*2}' file

Hope this explains and help...:wink:

Hey i got the solution

for(i=1;i<=3;i++)
do
Index=`awk 'NR=='$i' {print $2}' input`
value=Index+3000
echo $value

Thanks to all of u