'diff' 命令可以忽略不同类型的换行符吗?

can the 'diff' command ignore different kinds of line breaks?

我想检查在不同操作系统(Windows 和 OSX)上创建的两个 .txt 文档的相似性。使用 'diff' 命令输出文档每一行的差异,尽管其中许多“看起来”相同。

我记得在 Windows 和基于 Unix 的系统上使用的换行符之间存在差异,我认为这就是导致问题的原因。

diff 命令是否有忽略此差异的选项?我在手册页上找到了忽略所有空格的“-w”,但这并不是我真正想要的。

diff --strip-trailing-cr file1 file2

diff <(dos2unix < file_from_windows) file_from_osx

diff <(tr -d '\r' < file_from_windows) file_from_osx