| Doug McClure 2004-06-09, 3:55 am |
| I have done something like this:
FNR == 1 {
# First line of this file
FileNumber++
}
FileNumber == 1 {
# Compute value from A
Value_from_A = ...
}
FileNumber == 2 {
# Search file B
if (match($0, Value_from_A))
{
# Do something
}
}
match() is intended to use a string as its first argument and a
regular expression as its second, but I believe the Value_from_A
string will be converted to a regular expression.
This might be a problem if Value_from_A contains any escape
characters. If it's just plain ASCII, you should be OK as is.
DKM
On 8 Jun 2004 13:09:10 -0700, mehedi.hashir@ibx.com (mehedi) wrote:
>What i'm trying to do with awk
>1. read a record from the file A
>2. use the value retrieved from the file A in a search of file B
>
>Below are two statements i need to combine but don't now how.
>awk '{while ((getline tmp) > 0) print tmp;print NR;}' FILEA
>
>awk '/Value from file A/ , /END/' FILEB
> -------------
>
>Thanks
>
>Mehedi
To contact me directly, send EMAIL to (single letters all)
DEE_KAY_EMM AT EarthLink.net. [For example X_X_X@EarthLink.net.]
|