I agree with the comment of @Marc that you should try something before asking here.
However, the following answer is difficult to find when you never have seen the constructions, so I give you something to study.
When you want to parse line by line, you can start with
while IFS=: read -r file path mode; do
comparewith=$(grep "^${file}:${path}:" File2.txt | cut -d: -f3)
# compare and output
done < File1.txt
For large files that will become very slow.
You can first filter the lines you want to compare from File2.txt.
You want to grep
strings like aaa:/path/to/aaa:
, including the last :
. With cut -d: -f1-2
you might be fine with your inputfile, but maybe it is better to remove the last three characters:
sed 's/...$//' File1.txt
.
You can let grep use the output as a file with expressions using <()
:
grep -f <(sed 's/...$//' File1.txt) File2.txt
Your example files don't show the situation when both files have identical lines (that you want to skip), you will need another process substitution to get that working:
grep -v -f File1.txt <(grep -f <(sed 's/...$//' File1.txt ) File2.txt )
Another solution, worth trying yourself, is using awk
(see What is "NR==FNR" in awk? for accessing 2 files).