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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CaKiwi... Helllp 1

Status
Not open for further replies.

Homz

Technical User
Mar 25, 2003
1
US
Good day;

Few months ago, you had posted a small awk
program:

# a.awk
BEGIN {
FS = "|"
OFS = "|"
while ((getline < &quot;file2&quot;) > 0) {
j++
a1[j] = $1
sub(/^[^\|]*/,&quot;&quot;,$0)
a0[j] = $0
}
}
{
for (i=1;i<=j;i++) {
if ($1 == a1) {
print $2 &quot; &quot; a0
}
}
}

It was supposed to grab some output from
a file, then append it to another file
by adding a column. I could not get the
program to work. I am a newbie with awk
so really, I barely understand the code
(Thanks to the pseudo code provided by
in the thread)

I attempt to run it under solaris 8 and
this is the erros I get:

# awk -f a.awk file1 < file2 > file3
awk: syntax error near line 5
awk: illegal statement near line 5
awk: syntax error near line 8
awk: illegal statement near line 8
awk: syntax error near line 12
awk: bailing out near line 12

What am I doing wrong?

Thanks


 
1. when posting code - DISABLE the TGML
2. instead of using 'awk' - use 'nawk' vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
awk is obsolete
cd /bin (should be a link to /usr/bin)
mv awk awk.old
ln -s nawk awk
ln -s oawk awk.old
wenn you say awk the nawk is used
wenn you say oawk the awk.old is used

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top