i need to search for a single pattern in three different logs....what would be the best one line script????
grep "pattern" log1 log2 log3
but i want to differentiate results got from each of the logs...the above command will display all the results in one screen
eg:
log1
results
log2
results
log3
results
you have the results differentiated with the output of grep itself
grep pattern l1 l2 l3
l1: pattern
l2: pattern
l3: pattern
grep "pattern" log1 log2 log3 |
awk -F: ' { if ( file != $1 ) { file=$1; print file } sub(/^[^:]*:/,"",$0);print $0 } '