Soon I will be receiving a new file. I've asked the source system to put "TRAILER.1+0000007+1" for the trailer to indicate full receipt of file. I need to know how to separate TRAILER so I can use it in a if statement.
I used the tail command but not sure how to incorporate awk or sed. I just want to word TRAILER and I also want to separate 0000007 which is the file line count.
Here is an alternative way to do it just using awk (without tail ). Unless your input files are BIG, it is probably faster to let awk read the entire input file than it is to start up another process to run tail .
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
"TRAILER.1+0000007+1"
and a file named incomplete.txt containing the same 1st six lines, but missing the trailer line, running the above script (assuming you name it checker ) as:
With double quote " and period . as field separators, and the input above: the first field is the empty string before the first double quote, the second field is TRAILER , the third field is 1+0000007+1 and the fourth field is the empty string after the the trailing double quote.