Is it possible to execute another awk file from a awk file? Using an awk file I need to execute all awk files in a current folder. Is it possible to do such operations in awk?
In order to tell awk to use that file for its program, you type: awk -f source-file input-file1 input-file2 … The -f instructs the awk utility to get the awk program from the file source-file (see Command-Line Options). Any filename can be used for source-file .
No. NR==0 will NEVER be true. Please show us a sample of your input file and tell us in English what you are trying to extract from that file into the mail message you're trying to send. The condition will not be effective inside awk since data is piped to sendmail regardless.
Call External Command From awk awk + cp: Read input of a file list, and copy the files to a required destination with a defined name pattern. awk + md5sum: Read input containing a list of filenames, output the filename and the MD5 hash of the file.
Yes you can. You'll need to use the system()
function. I'm assuming you only want to run these scripts once. If so, you can add them to the BEGIN
block of your wrapper script:
BEGIN {
system("awk -f ./script1.awk")
system("awk -f ./script2.awk")
system("awk -f ./script3.awk")
}
If you have a large number of scripts that need to be executed, you can use a for
loop. Do make sure that your wrapper script isn't in the same directory as all the other awk
scripts you'd like executed, or it will be included in the glob of awk
scripts...
BEGIN {
system("for i in *.awk; do awk -f \"$i\"; done")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With