Reputation: 2446
I'm looking to feed grep a pattern file with -f, but add a literal tab before and after each pattern (from the file). This method will allow me to grep for an exact column match, since I am dealing with a tab-separated file.
Yes, I have to use Grep. Awk and perl can't seem to handle my large pattern file.
And Yes, I could just add tabs to the pattern file, but I have many pattern files, so that would take a long time, but if all fails, that is what I'll do.
This should be useful for anyone looking to do an exact column match inside of a tsv file.
Upvotes: 0
Views: 561
Reputation: 65871
I'd try adding the tabs "on the fly":
grep -f <(sed 's/^/\\t/; s/$/\\t/' patterns) [args...]
to let grep
interpret \t
as tabs.
Upvotes: 1