-
1
- #1
Good day;
Few months ago, you had posted a small awk
program:
# a.awk
BEGIN {
FS = "|"
OFS = "|"
while ((getline < "file2" > 0) {
j++
a1[j] = $1
sub(/^[^\|]*/,"",$0)
a0[j] = $0
}
}
{
for (i=1;i<=j;i++) {
if ($1 == a1) {
print $2 " " 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
Few months ago, you had posted a small awk
program:
# a.awk
BEGIN {
FS = "|"
OFS = "|"
while ((getline < "file2" > 0) {
j++
a1[j] = $1
sub(/^[^\|]*/,"",$0)
a0[j] = $0
}
}
{
for (i=1;i<=j;i++) {
if ($1 == a1) {
print $2 " " 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