The ethead routine in the wcstool package is cuurently used to assemble the initial flat file of header card values.
gethead -u *.fits STRUCTAZ PARANGLE PHIMOON PSYSNAME boo MILLUM In play directory: ls -1 /home/sco/acm_reduced/acm/2018*fits >list.0 I edit list.0 to make an easy example file cat list.0 /home/sco/acm_reduced/acm/20180114T013423.4_acm_sci_proc.fits /home/sco/acm_reduced/acm/20180114T013510.1_acm_sci_proc.fits /home/sco/acm_reduced/acm/20180403T110601.3_acm_sci_proc.fits /home/sco/acm_reduced/acm/20180403T111010.1_acm_sci_proc.fits /home/sco/acm_reduced/acm/20180403T111018.2_acm_sci_proc.fits % gethead -u @list.0 STRUCTAZ PARANGLE PHIMOON PSYSNAME boo MILLUM 20180114T013423.4_acm_sci_proc.fits 343.405525 327.377666 -99.000000 r ___ -99.000 20180114T013510.1_acm_sci_proc.fits 343.405525 327.377666 -99.000000 B ___ -99.000 20180403T110601.3_acm_sci_proc.fits 101.405994 117.124834 74.465355 g ___ 93.000 20180403T111010.1_acm_sci_proc.fits 100.670933 116.587591 70.571274 g ___ 93.000 20180403T111018.2_acm_sci_proc.fits 100.670933 116.587591 70.571198 g ___ 93.000 Notice that I include card that is never matched with anything in the headers (boo). % gethead -u @list.0 STRUCTAZ PARANGLE PHIMOON PSYSNAME boo MILLUM >a1 % sed 's/___/ nv /' a1 > a2 % cat a2 20180114T013423.4_acm_sci_proc.fits 343.405525 327.377666 -99.000000 r nv -99.000 20180114T013510.1_acm_sci_proc.fits 343.405525 327.377666 -99.000000 B nv -99.000 20180403T110601.3_acm_sci_proc.fits 101.405994 117.124834 74.465355 g nv 93.000 20180403T111010.1_acm_sci_proc.fits 100.670933 116.587591 70.571274 g nv 93.000 20180403T111018.2_acm_sci_proc.fits 100.670933 116.587591 70.571198 g nv 93.000 Finally, note that you can dump all of your card names into afile (like the list of FITS image names) and make a much more compact command line: % cat Pnames STRUCTAZ PARANGLE PHIMOON PSYSNAME boo MILLUM % gethead -u @list.0 @Pnames 20180114T013423.4_acm_sci_proc.fits 343.405525 327.377666 -99.000000 r ___ -99.000 20180114T013510.1_acm_sci_proc.fits 343.405525 327.377666 -99.000000 B ___ -99.000 20180403T110601.3_acm_sci_proc.fits 101.405994 117.124834 74.465355 g ___ 93.000 20180403T111010.1_acm_sci_proc.fits 100.670933 116.587591 70.571274 g ___ 93.000 20180403T111018.2_acm_sci_proc.fits 100.670933 116.587591 70.571198 g ___ 93.000