Diff -b and -w difference

From the diff manpage:

-b, --ignore-space-change
      ignore changes in the amount of white space

-w, --ignore-all-space
      ignore all white space

From this, I infer that the difference between the -b and -w options must be that -b is sensitive to the type of whitespace (tabs vs. spaces). However, that does not seem to be the case:

$ diff 1.txt 2.txt 
1,3c1,3
<     Four spaces, changed to one tab
<         Eight Spaces, changed to two tabs
<     Four spaces, changed to two spaces
---
>       Four spaces, changed to one tab
>               Eight Spaces, changed to two tabs
>   Four spaces, changed to two spaces
$ diff -b 1.txt 2.txt 
$ diff -w 1.txt 2.txt 
$

So, what is the difference between the -b and -w options? Tested with diffutils 3.2 on Kubuntu Linux 13.04.


The man page isn't very clear on that point, but the info page elaborates:

1.2 Suppressing Differences in Blank and Tab Spacing

The --ignore-tab-expansion (-E) option ignores the distinction between tabs and spaces on input. A tab is considered to be equivalent to the number of spaces to the next tab stop (*note Tabs::).

The --ignore-trailing-space (-Z) option ignores white space at line end.

The --ignore-space-change (-b) option is stronger than -E and -Z combined. It ignores white space at line end, and considers all other sequences of one or more white space characters within a line to be equivalent. With this option, diff considers the following two lines to be equivalent, where $ denotes the line end:

 Here lyeth  muche rychnesse  in lytell space.   -- John Heywood$
 Here lyeth muche rychnesse in lytell space. -- John Heywood   $

The --ignore-all-space (-w) option is stronger still. It ignores differences even if one line has white space where the other line has none. "White space" characters include tab, vertical tab, form feed, carriage return, and space; some locales may define additional characters to be white space. With this option, diff considers the following two lines to be equivalent, where $ denotes the line end and ^M denotes a carriage return:

 Here lyeth  muche  rychnesse in lytell space.--  John Heywood$
   He relyeth much erychnes  seinly tells pace.  --John Heywood   ^M$

For many other programs newline is also a white space character, but diff is a line-oriented program and a newline character always ends a line. Hence the -w or --ignore-all-space option does not ignore newline-related changes; it ignores only other white space changes.


Seems like it is spaces between words maybe more but this is my result:

diff 1.txt 2.txt 
1,2c1,2
< test
< next next
---
> te  st     
> next  next


diff -b 1.txt 2.txt 
1c1
< test
---
> te  st 

results from -w is nothing.