options with awk

Hi everybody,
I have some difficulties to use awk with the right options (as always): i have for example 3 fields:
IF-MIB::ifIndex.1
IF-MIB::ifIndex.2
IF-MIB::ifIndex.3
i want to use "while" to access to these records one by one
so i wrote this script but it didn t return the right value:

(small script which returns the 3 records) | awk 'BEGIN {FS="\n"} { i=1
while (i<4)
{ print $i
i++
}
}'

this returns me all records wheras i want only the first or the second (for example)
which corrections may i do to allow me to access to the right record
Thank you for you help

Not sure that I understand the question (or even what the while loop is for) but if you want to return the second record then just use...

(small script which returns the 3 records) | awk NR==2

"Process the file line by line" is just the function of awk!
I think you must go over it.

FS="\n", such statement is used just when you want to process file paragraph by paragraph. It may formatted as below:
---------------------------------
#para1 as $1
hihi
king is a good boy.
I am home_king.

#para2 as $2
I am the east of the end.
Welcome to linuxsir.org
----------------------------------
then you can state that BEGIN{FS="\n",RS=""} :slight_smile:

Don't modify FS carelessly. By default, FS=[ \t].