1

we have this line from postgresql.conf file

#BARMAN# archive_command = 'rsync -a %p barman@107.16.25.69:/var/lib/barman/main-db-server/incoming/%f'

I remove the word - #BARMAN# by the following sec syntax

sed '/archive_command/ s/#BARMAN#//g'

but the word archive_command not in the beginning of the line

as the following:

    archive_command = 'rsync -a %p barman@107.16.25.69:/var/lib/barman/main-db-server/incoming/%f'

while expected output should be

archive_command = 'rsync -a %p barman@107.16.25.69:/var/lib/barman/main-db-server/incoming/%f'

how to fix that?

  • sed '/archive_command/ s/#BARMAN#[ ]*//g' ? – Archemar Sep 13 '17 at 14:28
  • sed -E 's/^#BARMAN#[[:blank:]]//g' – Raman Sailopal Sep 13 '17 at 14:31
2

Notice that you are only replacing #BARMAN#, and not the space(s) afterwards.

To do that, use

sed '/archive_command/s/#BARMAN# *//'

or, to allow for tabs as well as spaces:

sed '/archive_command/s/#BARMAN#[[:space:]]*//'

This will remove the string and any number of spaces or tabs directly afterwards.

| improve this answer | |

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.