Use grep within table instead of a loop