Since there was no suitable solution with diff
, I generated:
- a file listing all new lines (using another internal processing)
- another file listing deleted lines (using another internal processing)
- the result of
diff --context=0 file1 file2 | grep "^\!"
Then I filtered the output of the 3rd file by removing all lines that were removed/added:
while read line
do
if ! ( grep -q -- "$line" $ADDED_LINES_FILE $REMOVED_LINES_FILE) ; then
echo "$line"
fi
done < diff_output > $TMP_FILE
mv $TMP_FILE diff_output