-
1
- #1
I'm assuming you made a mistake with the output you say you want. The following awk program
gives this output:
a | 1 | 2 | 3 | 4|
a | 3 | 4 | 5 | 6|
b | 1 | 2 | 3 | 4|
b | 3 | 4 | 5 | 6|
c | 1 | 2 | 3 | 4|
c | 3 | 4 | 5 | 6|
d | 7 | 8 | 9 | 10|
d | 11 | 12 | 13 | 14|
e | 7 | 8 | 9 | 10|
e | 11 | 12 | 13 | 14|
Run it by entering
awk -f a.awk file2 > file3
If this is not want you want, you will need to post a further explanation. CaKiwi
Code:
# 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[i]) {
print $2 " " a0[i]
}
}
}
a | 1 | 2 | 3 | 4|
a | 3 | 4 | 5 | 6|
b | 1 | 2 | 3 | 4|
b | 3 | 4 | 5 | 6|
c | 1 | 2 | 3 | 4|
c | 3 | 4 | 5 | 6|
d | 7 | 8 | 9 | 10|
d | 11 | 12 | 13 | 14|
e | 7 | 8 | 9 | 10|
e | 11 | 12 | 13 | 14|
Run it by entering
awk -f a.awk file2 > file3
If this is not want you want, you will need to post a further explanation. CaKiwi