sed + remove word from specific line

yael

we have this line from postgresql.conf file

#BARMAN# archive_command = 'rsync -a %p [email protected]:/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 [email protected]:/var/lib/barman/main-db-server/incoming/%f'

while expected output should be

archive_command = 'rsync -a %p [email protected]:/var/lib/barman/main-db-server/incoming/%f'

how to fix that?

Kusalananda

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related