I have several nagios config files that are looking quite ugly as the tabbing/spacing is all over the place making it hard to read.
My first thought was to have sed remove any groupings of two or more spaces and replace them with a tab ('\t'). Most lines are then:
<tab> string <tab> string
However the strings are of varying length so one or two tabes are needed. Initially I singled out the tabs one by one but there are too many. My current sed script is:
s/ \+ /\t/g
Is there any way in sed to do something like:
if first string is greater than X characters long put one tab after it, if first string is greater than Y characters long put two tabs after it and so on?