2010/1/26 jul <jul_...@yahoo.fr>: > I want to add a small extra difference which annoys me between bsd and > GNU sed > > $ echo Foo | sed 's/foo/fuu/i' > sed: 1: "s/foo/fuu/i": bad flag in substitute command: 'i' > > it seems bsd sed has no support for case-insenstive flag. right ?
I feel your pain. The I (or i) argument is a GNU extension. You can do something like: $ echo Foo | \ sed y/[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/[abcdefghijklmnopqrstuvwxyz] | \ sed s/foo/fuu/g That's pretty much what's explained as "Solution 1" here: http://www.linuxtopia.org/online_books/linux_tool_guides/the_sed_faq/sedfaq4_003.html That FAQ also mentions a couple of alternatives, some of which may be easier (but no longer use just sed). Unless someone actually competent feels that the I argument is a worthy addition to OpenBSD's sed and is ready to submit a diff? (FreeBSD sed appears to have the I argument, btw. No, I'm not saying OpenBSD should become FreeBSD, just that there may be BSD-licensed suitable code out there. Or maybe FreeBSD uses GNU sed -- I haven't checked.) regards, --ropers PS: Incidentally, this is how I wrote my first ever ROT13 command: echo Foo | \ sed y/[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/[NOPQRSTUVWXYZABCDEFGHIJKLM]/ | \ sed y/[abcdefghijklmnopqrstuvwxyz]/[nopqrstuvwxyzabcdefghijklm]/