awk help - conditionally merge 2 files
I have a 3 column file that represents a symbol table for a certain program image, generated directly using nm on every build.
0025e8dc T _IO_file_fopen
0025e71c T _IO_file_init
00352e1f T rtcTimeGet
I have another static file that specifies a number to correspond with certain functions, like so:
2 rtcTimeGet
What I want to do is create a new file that combines this information, and substitutes a 1 for anything thats in the nm dump but not the static file, like so:
1 0025e8dc T _IO_file_fopen
1 0025e71c T _IO_file_init
2 00352e1f T rtcTimeGet
Can awk do this? I've used it before to organize data but I've never tried to merge two files - and I can't find any useful information online about how to go about this.
Try something like this:
Run it like this:
Where "syms" contains the contents of the static file.
[Edited by - kinetik_mjg on June 3, 2006 7:47:41 AM]
#! /usr/bin/awk -f!main { syms[$2] = $1}main { if (syms[$3]) { print syms[$3] " " $0 } else { print 1 " " $0 }}
Run it like this:
nm foo.o > dump./bar.awk syms main=1 dump
Where "syms" contains the contents of the static file.
[Edited by - kinetik_mjg on June 3, 2006 7:47:41 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement