Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read Second file while Reading First File using getline in awk

Status
Not open for further replies.

radhanarra

Programmer
May 22, 2001
1
0
0
US
Hi friends,

i have one tricky problem with Getline method.i am getting an empty value into variable when i tried to Read second file with in main File(first file)using Getline method.
can any one help me to resolve this issue.i really appricate your cooeration.

first file contains one column
1
6
8
first file contains one column
a
b
c

#!/bin/ksh
x1="a2"
awk ' BEGIN { x=0 }
{
if ($1>3)
{
if (getline var < &quot;secondfile&quot;)
print var
}
else
{
print $1
}
}' firstfile
 
I really can't figure out what you want
besides getting the second file into the
variable &quot;var&quot; so this snippet may help
you a little:

{
for (x =1 ; x <= NR ; x++)
while (getline var < &quot;second&quot;) {
split(var, array, RS)
print array[x]
}
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top