I am trying to clean a Huge database of emails, but when I use the following Grep command, I get "Memory Exhausted" Error.
pv "Suppresion-List.txt" | grep -vf <(sed 's/^/^/; s/$/$/' EMAILS.txt) > RESULT.txt
The data set in both file are really huge like more than 5 Million emails, therefore the Linux server gives me "Memory Exhausted" Error.
Therefore I decided to split the file in into small files with 10,000 emails each to process.
split -d -l 10000 EMAILS.txt Segment
How to create a Bash Script with a loop, where it checks for the created split file in increasing order and starts processing from the first file created - Eg: Segment00
pv "Suppresion-List.txt" | grep -vf <(sed 's/^/^/; s/$/$/' Segment00) > RESULT.txt
...then automatically loop the same command and substitute the second segment file in the command - Eg: Segment01
pv "Suppresion-List.txt" | grep -vf <(sed 's/^/^/; s/$/$/' Segment01) > RESULT.txt
...carry the loop until the last segment and then finally terminate.
Can you please help me write such Bash script? I cannot figure out how to automatically substitute the segmented files in increasing order automatically in the loop to write a shell script.