Archive

Posts Tagged ‘ignore case’

sed – Case-insensitive search

December 1, 2011 Leave a comment

Problem:
Doing a case-insensitive search with sed.

Solution:

`/REGEXP/I’
`\%REGEXP%I’
The `I’ modifier to regular-expression matching is a GNU extension
which causes the REGEXP to be matched in a case-insensitive manner.

Example:

user@machine:~$ echo "someTHIng" | sed -n "/something/p"

user@machine:~$ echo "someTHIng" | sed -n "/something/Ip"
someTHIng
user@machine:~$ sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
Advertisements
Categories: bash, sed Tags: ,