Need help creating a script that does the following:
[*]Sort a file
[*]Compare the previous line "last field" with current line "last field"
[*]If they are the same, print output to a file
[*]If they are different print output to a new file
[*]The script should keep creating new files if the previous line "last field" does not match the current lines last field
i.e.
That wasn't much fun. Took me a while to clue into the fact that arrays are associative and not numeric. Sorting was a pain until I made the element name a combo of the the last field and a record number to guarantee uniqueness.
Without GAWK the function asorti() is unavailable so I'm hoping you have GAWK. I'm a little unsure what you describe about where the records end up but I think you mean.. All the records that match the last field go into unique files.
Thanks to everyone who replied. I was able to use the 1 liner posted by Guru, it worked perfectly. I appreciate all the time and effort everyone put into this.