LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-03-2010, 06:56 AM   #1
saiteju
LQ Newbie
 
Registered: Feb 2010
Posts: 6

Rep: Reputation: 0
ignore case in if statement shell scripting


How do i make my strings case-insensitive while comparing them with an if statement?

Thanks,
Sai.
 
Old 02-03-2010, 07:46 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Before testing, enable shell option nocasematch:
Code:
shopt -s nocasematch
 
Old 02-27-2010, 01:49 AM   #3
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,562

Rep: Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939
Or you can convert the case of your variables:

^^ or ,, works in version 4 of bash (http://tldp.org/LDP/abs/html/bashver...ASEMODPARAMSUB)

Or use tr to change case.
 
  


Reply

Tags
case, if


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Korn Shell Scripting case statement help!! wfdeng117 Programming 3 07-22-2008 10:51 AM
shell scripting question - IF statement copperfox Linux - Software 1 09-28-2007 09:22 AM
How do I use an If statement within a case in a Shell script?? crazygyhrous Programming 7 01-03-2006 06:41 AM
Case Statement With Aix Ksh Scripting ']['HeBroken AIX 2 02-09-2005 12:44 PM
KSH Scripting case statement..... ']['HeBroken Programming 1 12-10-2004 10:38 AM


All times are GMT -5. The time now is 04:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration