I use a utility to help modify text files, but when they are saved back to the disk the TAB's have been replaced with 4-space characters. I want to undo that.
I tried this:
# tr '^ ' '\011' <oldfile >newfile
But, this replaced the leading 4-spaces with 4TABs. Would sed be a better choice? There will be a few lines which will have 8-spaces that I'd like converted to 2-TABs.
So, what I'm looking for is a command to replace any instance of 4 spaces with a single TAB.
To help clarify, consider this example (using "_" to simulate a SPACE, and "<tab>" for TAB:
Original File:
This is line 1.
____This is line 2.
____This is line 3.
This is line 4.
________This is line 5.
Desire result:
This is line 1.
<tab>This is line 2.
<tab>This is line 3.
This is line 4.
<tab><tab>This is line 5.
Thanks folks!
I tried this:
# tr '^ ' '\011' <oldfile >newfile
But, this replaced the leading 4-spaces with 4TABs. Would sed be a better choice? There will be a few lines which will have 8-spaces that I'd like converted to 2-TABs.
So, what I'm looking for is a command to replace any instance of 4 spaces with a single TAB.
To help clarify, consider this example (using "_" to simulate a SPACE, and "<tab>" for TAB:
Original File:
This is line 1.
____This is line 2.
____This is line 3.
This is line 4.
________This is line 5.
Desire result:
This is line 1.
<tab>This is line 2.
<tab>This is line 3.
This is line 4.
<tab><tab>This is line 5.
Thanks folks!