Get patient + study headers # dcmdump teh-dcm-file |grep -E '^\(00(10,00[12]0|08,1030)\)' Get the whole thing for a number of DCM folders: # for f in *; do find $f -name '*.dcm' -type f |tail -n1 |xargs dcmdump |grep -E '^\(00(10,00[12]0|08,(005|103)0)\)'; echo; done