Any way to change the tab size of the diff command's output?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm on OSX and running a diff
command like this, to create side-by-side output:
$] diff -Bbwy --width=200 --suppress-common-lines file1.txt file2.txt > diff-output.txt
It outputs my diffs just fine, but it uses tabs for indentation of the output (alignment of the side-by-side middle line, etc). Additionally, the files in question also use tabs for indentation inside them, so the diff output has all these tab characters in them.
I want the output of diff
to have spaces, specifically 4-space's instead of tabs.
I know diff
supports the -t
option to do just that, but the problem is it uses a fixed size of 8-spaces for all tabs (not only the leading line indentation tabs from the original files, but also its alignment tabs to keep the middle line aligned, etc).
I've tried a variety of post-processing approaches to take the tabs (or spaces) from diff
output and shrink them to the desired size of 4-spaces, but that always just causes mis-alignments of the diff
side-by-side output.
Then I thought maybe I could pre-process the two files being diff
ed, using tab2space
or something like that, to get each file's line indentations from tabs to 4-spaces before diffing. But I can't work out how, without temporary files, to then get both of those pre-processed inputs piped into diff
.
Can that be done?
Or is there any other approach I've not tried? Any secret way to config/force diff -t
to just use 4-space tabs instead of 8?
osx diff whitespace
add a comment |Â
up vote
0
down vote
favorite
I'm on OSX and running a diff
command like this, to create side-by-side output:
$] diff -Bbwy --width=200 --suppress-common-lines file1.txt file2.txt > diff-output.txt
It outputs my diffs just fine, but it uses tabs for indentation of the output (alignment of the side-by-side middle line, etc). Additionally, the files in question also use tabs for indentation inside them, so the diff output has all these tab characters in them.
I want the output of diff
to have spaces, specifically 4-space's instead of tabs.
I know diff
supports the -t
option to do just that, but the problem is it uses a fixed size of 8-spaces for all tabs (not only the leading line indentation tabs from the original files, but also its alignment tabs to keep the middle line aligned, etc).
I've tried a variety of post-processing approaches to take the tabs (or spaces) from diff
output and shrink them to the desired size of 4-spaces, but that always just causes mis-alignments of the diff
side-by-side output.
Then I thought maybe I could pre-process the two files being diff
ed, using tab2space
or something like that, to get each file's line indentations from tabs to 4-spaces before diffing. But I can't work out how, without temporary files, to then get both of those pre-processed inputs piped into diff
.
Can that be done?
Or is there any other approach I've not tried? Any secret way to config/force diff -t
to just use 4-space tabs instead of 8?
osx diff whitespace
BTW, I believe that-bw
is redundant.âÂÂDo you find that it behaves differently from-b
?
â G-Man
Nov 5 '17 at 19:51
I don't know that I'm seeing any difference between-b
,-w
, and-bw
, but they seemed like they could be different as they're listed separately. Shrugs.
â Kyle Simpson
Nov 6 '17 at 20:45
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm on OSX and running a diff
command like this, to create side-by-side output:
$] diff -Bbwy --width=200 --suppress-common-lines file1.txt file2.txt > diff-output.txt
It outputs my diffs just fine, but it uses tabs for indentation of the output (alignment of the side-by-side middle line, etc). Additionally, the files in question also use tabs for indentation inside them, so the diff output has all these tab characters in them.
I want the output of diff
to have spaces, specifically 4-space's instead of tabs.
I know diff
supports the -t
option to do just that, but the problem is it uses a fixed size of 8-spaces for all tabs (not only the leading line indentation tabs from the original files, but also its alignment tabs to keep the middle line aligned, etc).
I've tried a variety of post-processing approaches to take the tabs (or spaces) from diff
output and shrink them to the desired size of 4-spaces, but that always just causes mis-alignments of the diff
side-by-side output.
Then I thought maybe I could pre-process the two files being diff
ed, using tab2space
or something like that, to get each file's line indentations from tabs to 4-spaces before diffing. But I can't work out how, without temporary files, to then get both of those pre-processed inputs piped into diff
.
Can that be done?
Or is there any other approach I've not tried? Any secret way to config/force diff -t
to just use 4-space tabs instead of 8?
osx diff whitespace
I'm on OSX and running a diff
command like this, to create side-by-side output:
$] diff -Bbwy --width=200 --suppress-common-lines file1.txt file2.txt > diff-output.txt
It outputs my diffs just fine, but it uses tabs for indentation of the output (alignment of the side-by-side middle line, etc). Additionally, the files in question also use tabs for indentation inside them, so the diff output has all these tab characters in them.
I want the output of diff
to have spaces, specifically 4-space's instead of tabs.
I know diff
supports the -t
option to do just that, but the problem is it uses a fixed size of 8-spaces for all tabs (not only the leading line indentation tabs from the original files, but also its alignment tabs to keep the middle line aligned, etc).
I've tried a variety of post-processing approaches to take the tabs (or spaces) from diff
output and shrink them to the desired size of 4-spaces, but that always just causes mis-alignments of the diff
side-by-side output.
Then I thought maybe I could pre-process the two files being diff
ed, using tab2space
or something like that, to get each file's line indentations from tabs to 4-spaces before diffing. But I can't work out how, without temporary files, to then get both of those pre-processed inputs piped into diff
.
Can that be done?
Or is there any other approach I've not tried? Any secret way to config/force diff -t
to just use 4-space tabs instead of 8?
osx diff whitespace
asked Nov 5 '17 at 18:05
Kyle Simpson
1033
1033
BTW, I believe that-bw
is redundant.âÂÂDo you find that it behaves differently from-b
?
â G-Man
Nov 5 '17 at 19:51
I don't know that I'm seeing any difference between-b
,-w
, and-bw
, but they seemed like they could be different as they're listed separately. Shrugs.
â Kyle Simpson
Nov 6 '17 at 20:45
add a comment |Â
BTW, I believe that-bw
is redundant.âÂÂDo you find that it behaves differently from-b
?
â G-Man
Nov 5 '17 at 19:51
I don't know that I'm seeing any difference between-b
,-w
, and-bw
, but they seemed like they could be different as they're listed separately. Shrugs.
â Kyle Simpson
Nov 6 '17 at 20:45
BTW, I believe that
-bw
is redundant.âÂÂDo you find that it behaves differently from -b
?â G-Man
Nov 5 '17 at 19:51
BTW, I believe that
-bw
is redundant.âÂÂDo you find that it behaves differently from -b
?â G-Man
Nov 5 '17 at 19:51
I don't know that I'm seeing any difference between
-b
, -w
, and -bw
, but they seemed like they could be different as they're listed separately. Shrugs.â Kyle Simpson
Nov 6 '17 at 20:45
I don't know that I'm seeing any difference between
-b
, -w
, and -bw
, but they seemed like they could be different as they're listed separately. Shrugs.â Kyle Simpson
Nov 6 '17 at 20:45
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
diff (options) <(expand -t4 file1.txt) <(expand -t4 file2.txt)will expand tabs in the input file to spaces,
assuming tab stops set every four columns.ÃÂ
Combining this with
diff
âÂÂs -t
option should get you what you want.
Awesome, that worked perfectly. I was trying|
and had completely forgotten about<
. :)
â Kyle Simpson
Nov 6 '17 at 20:35
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
diff (options) <(expand -t4 file1.txt) <(expand -t4 file2.txt)will expand tabs in the input file to spaces,
assuming tab stops set every four columns.ÃÂ
Combining this with
diff
âÂÂs -t
option should get you what you want.
Awesome, that worked perfectly. I was trying|
and had completely forgotten about<
. :)
â Kyle Simpson
Nov 6 '17 at 20:35
add a comment |Â
up vote
1
down vote
accepted
diff (options) <(expand -t4 file1.txt) <(expand -t4 file2.txt)will expand tabs in the input file to spaces,
assuming tab stops set every four columns.ÃÂ
Combining this with
diff
âÂÂs -t
option should get you what you want.
Awesome, that worked perfectly. I was trying|
and had completely forgotten about<
. :)
â Kyle Simpson
Nov 6 '17 at 20:35
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
diff (options) <(expand -t4 file1.txt) <(expand -t4 file2.txt)will expand tabs in the input file to spaces,
assuming tab stops set every four columns.ÃÂ
Combining this with
diff
âÂÂs -t
option should get you what you want.diff (options) <(expand -t4 file1.txt) <(expand -t4 file2.txt)will expand tabs in the input file to spaces,
assuming tab stops set every four columns.ÃÂ
Combining this with
diff
âÂÂs -t
option should get you what you want.answered Nov 5 '17 at 19:51
G-Man
11.6k82657
11.6k82657
Awesome, that worked perfectly. I was trying|
and had completely forgotten about<
. :)
â Kyle Simpson
Nov 6 '17 at 20:35
add a comment |Â
Awesome, that worked perfectly. I was trying|
and had completely forgotten about<
. :)
â Kyle Simpson
Nov 6 '17 at 20:35
Awesome, that worked perfectly. I was trying
|
and had completely forgotten about <
. :)â Kyle Simpson
Nov 6 '17 at 20:35
Awesome, that worked perfectly. I was trying
|
and had completely forgotten about <
. :)â Kyle Simpson
Nov 6 '17 at 20:35
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402696%2fany-way-to-change-the-tab-size-of-the-diff-commands-output%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
BTW, I believe that
-bw
is redundant.âÂÂDo you find that it behaves differently from-b
?â G-Man
Nov 5 '17 at 19:51
I don't know that I'm seeing any difference between
-b
,-w
, and-bw
, but they seemed like they could be different as they're listed separately. Shrugs.â Kyle Simpson
Nov 6 '17 at 20:45