Home > bash, sed > sed – Case-insensitive search

sed – Case-insensitive search

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: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: