0

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 '18 at 17:25
0

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.