Case Insensitive Grep Search

Posted on 2003-03-14
Medium Priority
Last Modified: 2013-12-25

I have the following piece of code to search an array for a user specified value:
@packages = grep /$value/, @array;

However, the search is case sensitive, so I tried adding the -i flag for grep:
@packages = grep -i /$value/, @array;

Unfortunately this causes the code compilation to fail, giving me the following error message:

"Software error:
Unrecognized file test: -i at [file name, line number]"

Am I using the -i flag wrong?  Or is there another way to do this?
Any help would be greatly appreciated.  Thanks in advance.
Question by:_Dan_
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 17

Accepted Solution

dorward earned 200 total points
ID: 8136873
@packages = grep /$value/i, @array;

I _think_ that will do the trick.

Author Comment

ID: 8136904
Perfect!  Thanks a lot.

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question