#!/usr/bin/gawk -f BEGIN{ IFS=" "; } /^[a-fA-F0-9]{32} \S+/{ files[$2] = 1; } /^[a-fA-F0-9]{40} \S+/{ files[$2] = 1; } /^[a-fA-F0-9]{128} \S+/{ files[$2] = 1; } END{ for(file in files){ print file } }