How to specify a sed
regexp address which is case-insensitive?
E.g.,
sed '/my-kw/d'
But I want sed
to remove lines with my-kw
in any cases.
Thanks
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communitysed '/my-kw/Id'
This will perform the match case-insensitive.
The switch is in uppercase itself, to avoid confusion with the i
command that is offered by sed
to insert a line into the stream.
C
was removed from the list. You can run the sample your self jot -c 5 'A' | tee /dev/tty | sed '/c/Id'
, where the jot is from the athena-jot package under Debian/Ubuntu.
Just use the I
switch:
$ echo fooFOO | sed 's/o/a/Id'
faaFaa
From the sed
FAQ:
GNU sed 3.02 and ssed also offer the /I switch for doing a case-insensitive match. For example,
echo ONE TWO | sed "s/one/unos/I" # prints "unos TWO"
n
- quiet and p
- print flag to print part of a line: $(dhclient $eth|sed -nr 's/rtnetlink answers: (.*)/\1/Ip')
. But the caseinsensitive does not work. Actual behaviour RTNETLINK answers: Operation not permitted
, expected Operation not permitted
. Same $(dhclient $eth|sed -r 's/rtnetlink answers: (.*)/\1/I')
This might work for you:
sed '/[mM][yY]-[kK][wW]/d' file or:
sed 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;/MY-KW/d;x' file