I have an awk script named text_processing.awk . I need to pass multiple zipped files named 01JAN21.txt.gz , 02JAN21.txt.gz etc. to this script for further processing. The output file takes the date from the input file and gets named result_01JAN21.txt and so on.
Please note the files are zipped.
I tried running on one file at first using command below
zcat 01JAN21.txt.gz | awk -f text_processing.awk -
However, my output file doesn't get named, I believe because this command just opens the file and pipes it to the script, whereas, my script extracts date from the input file name as below
BEGIN{
FS = ";"
input_file = ARGV[1]
sub(/\.txt\.gz/, "", input_file)
output = "result_" input_file ".txt
}
Will appreciate some guidance on how to go about rectifying it. I want to keep the renaming of output file within awk script because there are multiple files I will be passing at one go.