In my current job I often have to work with files from Windows machines which most of the time isn't a big deal, but when piping a side-by-side diff
to less
, not only are the ^M
being displayed, but it also messes up the indentation, like in the following:
<U+FEFF>using System;^M <U+FEFF>using System;^M
using System.Reflection;^M using System.Reflection;^M
using System.Runtime.Serializa^M using System.Runtime.Serializa^M
using System.Transactions;^M using System.Transactions;^M
(I don't particularly mind the UTF-8 BOM in the first line, as it affects only that one line.)
I know I can do a
diff -y <(tr -d '\015' < file-a) <(tr -d '\015' < file-b) | less
But that's a heck of a lot to type, and when file-a
and file-b
share a long path, you can't use bash's curly braces nicety. And
diff -y file-{a,b} | tr -d '\015' | less
does not do the trick, as the formatting is already messed up.
Interestingly though, the following displays fine both in terms of ^M
and indentation:
diff -y file-{a,b} | head
So my question is, how do I get side-by-side diffs piped into less without the aforementioned issues?
Aucun commentaire:
Enregistrer un commentaire