Date: Thu, 28 May 2009 18:18:36 +0530 From: Manish Jain <invalid.pointer@gmail.com> To: FreeBSD Mailing List <freebsd-questions@freebsd.org> Cc: Roland Smith <rsmith@xs4all.nl> Subject: Need sed to do something which sounds simple Message-ID: <4A1E8824.1020604@gmail.com>
next in thread | raw e-mail | index | archive | help
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 invalid.pointer@gmail.com +91-96500-10329 Laast year I kudn't spell Software Engineer. Now I are won.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A1E8824.1020604>