rsnapshot is quite picky in its config: the commands have to be separated by TABs and not spaces.

if you use

rsnapshot configtest

you see the errors, but how can I automatically repair the errors and replace multiple space with tabs in the region where it is a problem?

I could use sed:

sed s/\s+/\t/g

but that would change the whole file.

  • Can you give an example of the config file, preferably with both examples for a space that should be replaced and one that should not?
    – Jeff Schaller
    Dec 19, 2018 at 17:25

1 Answer 1


Based on some arbitrary files online (1 and 2), I came up with a sed statement that replaces spaces after text that looks like a command (letters and underscores) with a single tab:

sed 's/^\([a-z_][a-z_]*\)  */\1\t/' input > output

The escaped parenthesis capture the command (one or more letters & underscores, starting at the beginning of the line (^)), then require one or more spaces to follow that command; those patterns get replaced by the matched command (\1) and a tab. This pattern match skips commented out lines (because # is not a letter or underscore).

  • 1
    This only replaces the space in the first gap, for example backup /etc/ localhost/ has two gaps, which could contain spaces instead of tabs
    – rubo77
    Jul 1, 2019 at 21:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .