I'm trying to filter lines for a big txt file (around 10GB) bashed on prefix of called number only when the direction column equals 2.
This is the format of the file that i'm getting from pipe (from a different script)
caller_number=34234234324, clear_number=982545345435, direction=1, ...
caller_number=83479234234, clear_number=348347384533, direction=2, ...
Of cause this is just an example data but the actual file contains many other columns but I want to only filter the clear_number column based on direction so this is enough.
I want to remove lines that do not contain a list of prefixes, so for example here I would do that with grep with the following:
grep -vP 'clear_number=(?!(2207891|22034418|22074450|220201677|220240574|220272183|220722988|220723276|220751152|220774457|220794227|220799141|2202000425|2202000939|2202000967)).*direction=2'
This works beautifully. The only problem is that the number of prefixes that I get is sometimes around 10K-50K, this is a lot of prefixes, and if I try to do that using grep
I get grep: regular expression is too large.
Any ideas how else to resolve it using Bash commands?
update
example.. lets say i have the following:
caller_number=34234234324, clear_number=982545345435, direction=1
caller_number=83479234234, clear_number=348347384533, direction=2
caller_number=2342334324, clear_number=5555345435, direction=1
caller_number=034082394234324, clear_number=33335345435, direction=1
caller_number=83479234234, clear_number=348347384533, direction=2
caller_number=83479234234, clear_number=444447384533, direction=2
caller_number=83479234234, clear_number=64237384533, direction=2
and my list.txt contains:
642
3333
534234235
so it will only return the line
caller_number=83479234234, clear_number=64237384533, direction=2
since clear number starts with 642 and direction=2. just in my case it will go over 10GB of text file and return at least 100K of results.
another update
i'm sorry i wasn't clear about one more thing. i get the lines from a pipe command, so i should do | awk... on the output i receive form previous commands.