grep "pattern" log1 log2 log3 | awk -F: ' { if ( file != $1 ) { file=$1; print file } sub(/^[^:]*:/,"",$0);print $0 } '