I use awkto format the input file in the output file. I have several templates for populating variables (for example, "some template" in the example). These variables are printed in the required format in the block END. The result must be done there, because the order of appearance in the input file is not guaranteed, but the order in the output file must always be the same.
BEGIN {
FS = "=|,"
}
/some pattern/ {
if ($1 == 8) {
var = $1
} else {
exit 1
}
}
END {
print var
}
, - exit . , , , , . gawk () , exit , END . exit :
if (!exit_invoked) {
print var
}
- END?
edit: shellter.