.. wrap it in a loop?
for f in <files>; do
echo "$f";
awk -v start=$(head -n 1 "$f") -v end=$(tail -n 1 "$f") -f script file2;
done
Personally I would suggest combining them on one line (so that your results are block-data as opposed to file names on different lines from their results -- in that case replace echo "$f"
with echo -n "$f "
(to not add the newline).
EDIT: Since I suppose you're new to the syntax, <files>
can either be a list of files (file1 file2 file 3
), a list of files as generated by a glob (file*
, files/data_*.txt
, whatever), or a list of files generated by a command ( $(find files/ -name 'data' -type f)
, etc).