Find Difference between Two Text Files - Case 2
【Question】
I have a pattern file and another text file. I want to find the patterns in the pattern file which are missing in the text file. The whole lines in the pattern file will do. Is there any Bash/grep/Awk solutions?
while read config_opt
do
if ! grep $config_opt $your_text_file > /dev/null 2>&1; then
echo -e $config_opt;
fi
done < $your_pattern_file
【Answer】
You can find the difference between “pattern file” and “another text file” in grep. But it is slow. Here I’ll use esProc SPL (Structured Process Language) to handle your question. esProc enables more algorithms and much better performance. Here’s the SPL script:
A |
|
1 |
=file("E:\\\file1.txt").cursor() |
2 |
=file("E:\\\file2.txt").cursor() |
3 |
=[A1.sortx(_1),A2.sortx(_1)].mergex@xd(_1) |
4 |
=file("E:\\result.txt").export(A3) |
If “another text file” is relatively small, then you can read it into the memory. esProc encapsulates a rich variety of functions for memory data processing, such as associated computation, multi-file query and merge query to implement complicated algorithms and logics effortlessly.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL