-4

The text in file looks like this:

 [homes]
            comment = Home Directories
            path = 
            browseable = 
            writable = yes
            valid users = %S
            valid users = MYDOMAIN\%S

[printers]
        comment = All Printers
        path = /var/spool/samba
        browseable = no
        guest ok = no
        writable = no
        printable = yes

I want output as:

[homes]
        comment = Home Directories
        path = /data
        browseable = yes
        writable = yes
        valid users = %S
        valid users = MYDOMAIN\%S

[printers]
        comment = All Printers
        path = /var/spool/samba
        browseable = no
        guest ok = no
        writable = no
        printable = yes

I am using this command:

sed -i "\#path# s#.*#& /data#" file

It makes changes to everywhere in file where path is located.

Can anyone help me with this?

Rishav
  • 1
  • 2
  • 2
    Rather than posting the same question again, please explain in your last question why the given solution does not work for you. – Kusalananda Sep 21 '17 at 06:27
  • If there are other sections with empty path =, you probably want to apply to the homes section only: sed '/\[homes/,/browsable/s#path =.*#path = /data#' – Philippos Sep 21 '17 at 06:32

1 Answers1

1

If you just want to change the indention, this will do the job:

sed 's/ \{12\}/        /' file

It takes 12 sequent space characters (\{12\}) and replaces them by eight spaces.

dessert
  • 1,687