Hi,

I need sed to do something which sounds simple, but I can't figure out the right command. All I need to do is insert a blank after a '}' at the end of a line if the next line begins immediately afterwards (i.e. with no blank line between).

//abc.cpp :
int myclass::fx(int * arg)
{
        if(! (isValid()))
        {
                return -1;
        }
        return ptr->fx(arg);
}

//what-i-want.cpp :
int myclass::fx(int * arg)
{
        if(! (isValid()))
        {
                return -1;
        }
        
        return ptr->fx(arg);
}

The commands I have tried are :

i)
sed -e 's/\(}$\)\n\(^[[:space:]]*[[:alpha:]]\+\)/\1\n\n\2/' \
<abc.cpp  >what-i-want.cpp

ii)
sed -e 's/\(}$\)\(^[[:space:]]*[[:alpha:]]\+\)/\1\n\2/' \
<abc.cpp  >what-i-want.cpp

but obviously neither works, which is why posting this message.

Can anybody please tell me what the correct command would be like ?


Thank you &
--
Regards
Manish Jain
[email protected]
+91-96500-10329

Laast year I kudn't spell Software Engineer. Now I are won.
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"

Reply via email to