Skip to main content
added 14 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k

The other answers here might be out of date. As of coreutils 3.5 diffdiff can indeed produce colored output which is turned off by default when the stdout is not a console.

From the man page:

 --color[=WHEN] colorize the output; WHEN can be 'never', 'always', or 'auto' (the default) 

--color[=WHEN]
colorize the output; WHEN can be never, always, or auto (the default)

To force color output when stdout is a pipe diff --color=always $file1-- $file2"$file1" "$file2" | less -rR should work.

The other answers here might be out of date. As of coreutils 3.5 diff can indeed produce colored output which is turned off by default when the stdout is not a console.

From the man page:

 --color[=WHEN] colorize the output; WHEN can be 'never', 'always', or 'auto' (the default) 

To force color output when stdout is a pipe diff --color=always $file1 $file2 | less -r should work.

The other answers here might be out of date. As of coreutils 3.5 diff can indeed produce colored output which is turned off by default when the stdout is not a console.

From the man page:

--color[=WHEN]
colorize the output; WHEN can be never, always, or auto (the default)

To force color output when stdout is a pipe diff --color=always -- "$file1" "$file2" | less -R should work.

Source Link
Kshitiz Sharma
  • 9.1k
  • 22
  • 62
  • 77

The other answers here might be out of date. As of coreutils 3.5 diff can indeed produce colored output which is turned off by default when the stdout is not a console.

From the man page:

 --color[=WHEN] colorize the output; WHEN can be 'never', 'always', or 'auto' (the default) 

To force color output when stdout is a pipe diff --color=always $file1 $file2 | less -r should work.