3 added 4 characters in body
source | link
diff -w file1 file2

The -w flag to diff will make it ignore whitespace characters (this is an extension implemented by most diff implementations).

With the following input:

file1:

hello world

abc
123

this is line 2 (the last line)

file2:

        hello   world

abc
123

this is line 3 (the last line)

The command generates

6c6
< this is line 2 (the last line)
---
> this is line 3 (the last line)

To make it ignore empty lines, pre-process the input files by removing empty lines. Using a shell that understands process substitution (like bash or ksh93):

diff -w <( sed '/^[^[[:space:]*$]]*$/d' file1 ) <( sed '/^[^[[:space:]*$]]*$/d' file2 )

If your diff has an option for ignoring blank lines (look for -B in the manual if you're using GNU diff) then use that. Mine does not have such an option.

diff -w file1 file2

The -w flag to diff will make it ignore whitespace characters (this is an extension implemented by most diff implementations).

With the following input:

file1:

hello world

abc
123

this is line 2 (the last line)

file2:

        hello   world

abc
123

this is line 3 (the last line)

The command generates

6c6
< this is line 2 (the last line)
---
> this is line 3 (the last line)

To make it ignore empty lines, pre-process the input files by removing empty lines. Using a shell that understands process substitution (like bash or ksh93):

diff -w <( sed '/^[:space:]*$/d' file1 ) <( sed '/^[:space:]*$/d' file2 )
diff -w file1 file2

The -w flag to diff will make it ignore whitespace characters (this is an extension implemented by most diff implementations).

With the following input:

file1:

hello world

abc
123

this is line 2 (the last line)

file2:

        hello   world

abc
123

this is line 3 (the last line)

The command generates

6c6
< this is line 2 (the last line)
---
> this is line 3 (the last line)

To make it ignore empty lines, pre-process the input files by removing empty lines. Using a shell that understands process substitution (like bash or ksh93):

diff -w <( sed '/^[[:space:]]*$/d' file1 ) <( sed '/^[[:space:]]*$/d' file2 )

If your diff has an option for ignoring blank lines (look for -B in the manual if you're using GNU diff) then use that. Mine does not have such an option.

2 added 245 characters in body
source | link
diff -w file1 file2

The -w flag to diff will make it ignore whitespace characters (this is an extension implemented by most diff implementations).

With the following input:

file1:

hello world

abc
123

this is line 2 (the last line)

file2:

        hello   world

abc
123

this is line 3 (the last line)

The command generates

6c6
< this is line 2 (the last line)
---
> this is line 3 (the last line)

To make it ignore empty lines, pre-process the input files by removing empty lines. Using a shell that understands process substitution (like bash or ksh93):

diff -w <( sed '/^[:space:]*$/d' file1 ) <( sed '/^[:space:]*$/d' file2 )
diff -w file1 file2

The -w flag to diff will make it ignore whitespace characters (this is an extension implemented by most diff implementations).

With the following input:

file1:

hello world

abc
123

this is line 2 (the last line)

file2:

        hello   world

abc
123

this is line 3 (the last line)

The command generates

6c6
< this is line 2 (the last line)
---
> this is line 3 (the last line)
diff -w file1 file2

The -w flag to diff will make it ignore whitespace characters (this is an extension implemented by most diff implementations).

With the following input:

file1:

hello world

abc
123

this is line 2 (the last line)

file2:

        hello   world

abc
123

this is line 3 (the last line)

The command generates

6c6
< this is line 2 (the last line)
---
> this is line 3 (the last line)

To make it ignore empty lines, pre-process the input files by removing empty lines. Using a shell that understands process substitution (like bash or ksh93):

diff -w <( sed '/^[:space:]*$/d' file1 ) <( sed '/^[:space:]*$/d' file2 )
1
source | link

diff -w file1 file2

The -w flag to diff will make it ignore whitespace characters (this is an extension implemented by most diff implementations).

With the following input:

file1:

hello world

abc
123

this is line 2 (the last line)

file2:

        hello   world

abc
123

this is line 3 (the last line)

The command generates

6c6
< this is line 2 (the last line)
---
> this is line 3 (the last line)