Do we know how to read input file within awk script and send output toanother log file. All this needs to be in awk script, not in command line. I am running this awk through crontab.
Cat my.awk
#!/bin/awk -f
function test(var){
some code}
{
}
END
{
print"test code"
}
What do you want to achieve?
Just some simple redirection for which you do not need awk at all, or
plain processing of a file by awk and redirecting the output, or
processing a file of input with awk while having a 2nd file being processed too?
Processing a file of input and redirecting the output to another file. How Would I put input file name and out put file name in awk script, not thru command line
Anyway, you use awk in a shell script the same way as you do that in a shell.
In your code like example, you used -f to give awk a script file. The last argument is always the file name of the file to be processed (for example data, logs...).
I see no easy way to do that, that is not awkward. Neither do I see a reason why this has to be done. What is the reason if I may ask? Why not just use a shell script that calls awk?
Maybe someone else has an idea how to do that the way you want it.