I am reasonably capable with awk and its quirks, but not with shell weirdness. This has to be Bourne Shell for portability reasons. I have an awk program that is working just fine; it handles multiple input streams and produces several reports, based on the request (-v Variables). In addition to processing the stream, and producing the required report in
the stream (so that it can be re-directed, etc), I write certain errors to a separate
Now I need to enhance the program, to write to a specific filename (constructed per execution, no problem), and to sort the contents.
I used the Site Search but nothing similar came up, due to the hundreds of badly formed thread titles.
The generic question may be as simple as the thread title.
This code snippet contains the seed of the problem, in simple form. The last two lines of code is a statement of intent; obviously it does not work as is.
## constructed, simple form provided
ERR_FILE = "SERVER_yymmdd_Err.dat"
ERR_FILE_TMP = "/tmp/SERVER_yymmdd_Err.dat"
## many of these; works fine
if ( Foo != Bar ) printf Value_DMP, Foo, Bar > ERR_FILE_TMP
printf "SERVER\t%s %s\n", SERVER, DATE > ERR_FILE
## need to get the filename out to the shell
## this states intention:
system( "sort ERR_FILE_TMP >> ERR_FILE" )
system( "rm ERR_FILE_TMP" )