There has to be a way to do this with awk or maybe I'm just focusing on the wrong tool and making this harder than it needs to be.
I'm trying to do a file field lookup/join at a very large scale but the output changes has to change dramatically. I have an input file to do a field lookup from and essentially do a field join out output with a one to many relationship of values that will be found. For each result, I need to write out a block of text based on results found.
If results are found, data is pulled together. If there's multiple results found in the data file, then it needs to organize the somewhat like the below. If no results are found, then it just uses field values from the original file. Once that is done to determine fields, then the output has to be output way different on separate lines.
3) Output text to write out (site value from file1 is dropped if results found and overriding site values used where a location can have multiple side ids):
Site Id: 12
Site Id: 13
Site Id: 14
Site Id: 10
Site Id: 99
Site Id: 100
Site Id: 4
I've looked at this at a few different ways. And I'm getting myself turned around. Can you help?
Please use CODE tags when displaying sample input, output, and code segments.
Last edited by Don Cragun; 11-13-2017 at 06:19 PM..
Reason: Add CODE tags.
Welcome to the UNIX & Linux Forums. When starting a thread here it always helps if you tell us what operating system and shell you're using so we know what capabilities your system has.
In addition to what Yoda suggested, you might also try the following. By reversing the order in which the files are processed, it can process records from File1.txt one record at a time instead of having to store the entire contents of both files in memory.
You guys rock. I was doing this within a Cygwin bash shell and within an AIX OS bash shell. I was close to what Yoda was doing but can see now with his example where my code was starting to go wrong. Due to the suggestion of Don, I was focusing on testing that and it worked like a charm. Thanks for the help.