Reputation: 3393
How can I call an awk script from an awk script and assign the output of the first to a variable in the second?
I have an awk script that reads files each night, checks each line of data and writes to a new file. I need to add in some additional formatting to one of the fields. I already have a standalone awk script that does the formatting so all I need to do is call this awk script for the appropriate fields and assign the value that is normally printed to a variable.
To put it in context, the following prints the required formatting to the screen (because that's what title_case.awk does), but I can’t use the value for further processing.
print old_name | ("/production/bin/title_case.awk")
so I need something like the following:
new_name = 'old_name | ("/production/bin/title_case.awk")
Thanks,
Ger
Upvotes: 0
Views: 338
Reputation: 40778
You can try using getline
into a variable ( http://www.gnu.org/software/gawk/manual/gawk.html#Getline_002fVariable_002fPipe )
("/production/bin/title_case.awk "old_name) | getline new_name
Upvotes: 1