1753556 Members
5756 Online
108796 Solutions
New Discussion юеВ

Re: help script sed

 
SOLVED
Go to solution
Jairo Campana
Trusted Contributor

help script sed

Helo I need insert a [INTRO] after of flag }; :
in file test.conf
I execute : cat test.conf | sed "/^$/d" | sed "s/^};/};\n/g"

\n ---> [INTRO] its no work

the file is
cat test.conf:
};
zone "10.1.1.11.in-addr.arpa" in {
type master;
notify no;
file "rev/101.101.102.in-addr.arpa";
};
zone "10.1.1.11.in-addr.arpa" in {
type master;
notify no;
file "rev/10.1.1.12.in-addr.arpa";
};
zone "10.1.12.in-addr.arpa" in {
type master;
notify no;
file "rev/10.1.1.11.in-addr.arpa";
};


the exit would have to be:
cat test.conf
};

zone "10.1.1.11.in-addr.arpa" in {
type master;
notify no;
file "rev/101.101.102.in-addr.arpa";
};

zone "10.1.1.11.in-addr.arpa" in {
type master;
notify no;
file "rev/10.1.1.12.in-addr.arpa";
};

zone "10.1.12.in-addr.arpa" in {
type master;
notify no;
file "rev/10.1.1.11.in-addr.arpa";
};



legionx
3 REPLIES 3
Sandman!
Honored Contributor

Re: help script sed

give the sed script below a try.

sed '{
/^$/d
/^};$/a\

}' infile
James R. Ferguson
Acclaimed Contributor
Solution

Re: help script sed

Hi:

How about this approach:

# perl -pe 's/^\s+$//;s/^};/};\\n/g;s/\\n/\n/g;' file

Regards!

...JRF...
Jairo Campana
Trusted Contributor

Re: help script sed

solved , thanks
legionx