rhnaeco
Technical User
- Aug 11, 2005
- 45
i know this is easy and i should use arrays- however despite reading about them i still don't quite understand:
i have two files one containing:
1 Tidal Prism = 1.20397e+08 m2
the other:
1 profile area = 12309.8 m2
2 profile length = 1.06403 km
all i want to do is create a file like this which will be added to later:
1.20397e+0 12309.8
i have tried:
awk '
BEGIN {
while (getline < "tp1.txt")
{prism[$5]=1}
}
{
if ($3 == "area")
print prism[$5], $5
}' tp2.txt
but just get
1.20397e+08
i have also tried:
awk '{
if ($1 == "1")
print $5
}' tp1.txt tp2.txt
which works but obviously gives the answer in a column, rather than a line
as i said- i know the array is the problem but how do i know what x and y equals in name[x]=y, using my files as an example- i have seen y=1, y=$3, x=$1,$3 -help!!!!
thanks
rhnaeco
i have two files one containing:
1 Tidal Prism = 1.20397e+08 m2
the other:
1 profile area = 12309.8 m2
2 profile length = 1.06403 km
all i want to do is create a file like this which will be added to later:
1.20397e+0 12309.8
i have tried:
awk '
BEGIN {
while (getline < "tp1.txt")
{prism[$5]=1}
}
{
if ($3 == "area")
print prism[$5], $5
}' tp2.txt
but just get
1.20397e+08
i have also tried:
awk '{
if ($1 == "1")
print $5
}' tp1.txt tp2.txt
which works but obviously gives the answer in a column, rather than a line
as i said- i know the array is the problem but how do i know what x and y equals in name[x]=y, using my files as an example- i have seen y=1, y=$3, x=$1,$3 -help!!!!
thanks
rhnaeco