问题描述:

I would like to be able to diff a file in a way that would split each new 'line' by '.' as opposed to '\n'

Is there any way to do this with the standard diff command?

My end goal of doing this is being able to do git diffs on plain text files that aren't filled with newlines.

网友答案:

Just use tr on the input files (and avoid a temporary file by using process substitution, a feature of bash):

diff -u <(tr . '\n' < file1) <(tr . '\n' < file2)

To integrate with git, you'll need to define a custom diff driver as per gitattributes(5), under Generating diff text

相关阅读:
Top