Run external command with awk: example with cat command.
In the example below, you pass the filename myfilename.pdb
to awk variable x
and cat
the content of the file each time MODEL
is present in column 1 of the inputfilename.pdb
:
rec=myfilename.pdb
awk -v x=$rec '{if ($1=="MODEL") system("cat " x); else {print $0}}' inputfilename.pdb