Expanding @steeldriver's answer to other `awk` implementations without `BEGINFILE` and `ENDFILE` makes it a bit messier, but portable:
awk -F'^' 'FNR==1{if (NR>FNR) printf("%s : Total characters in (Var) and (Lab) are %d\
",lastfile,sum); sum=0; lastfile=FILENAME} \
NF==2 && ($1=="var" || $1=="lab") {sum+=length($2)} \
END{printf "%s: Total characters in (Var) and (Lab) are %d\
", FILENAME, sum}' abc.txt def.txt
To explain:
* At beginning of file, (i.e. `FNR`, the per-file-line counter, is 1), we store the filename in a temporary variable `lastfile` and set the counter variable to 0.
* If this is not the first file (i.e. `NR`, the global line-counter, is larger than `FNR`), we output the statistics from the previous file.
* Since this rule would not catch the last file on `awk`'s argument list, we have to replicate the logic also in the global `END` block.