The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need help in IF condition!! raghav1982 Shell Programming and Scripting 12 03-28-2008 10:35 AM
Need help in While Condition raghav1982 Shell Programming and Scripting 5 10-30-2007 02:11 PM
if..else condition dr46014 Shell Programming and Scripting 3 10-29-2007 07:14 PM
if condition ravi raj kumar Shell Programming and Scripting 1 04-06-2007 02:01 AM
if condition mahabunta UNIX for Dummies Questions & Answers 1 09-26-2006 07:47 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-13-2007
Registered User
 

Join Date: Aug 2006
Posts: 45
if condition ...

i have following if condition

if [ "$data_type" == "ASCII" ]

above statement is case sensitive.....what is syntax if i have to make above comparision case insensetive
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-13-2007
djp djp is offline
Registered User
 

Join Date: Apr 2005
Posts: 13
Code:
if [ "$data_type" = "ASCII" ] || \
   [ "$data_type" = "ascii" ]
Reply With Quote
  #3 (permalink)  
Old 02-13-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,391
Code:
case "$data_type" in [Aa][Ss][Cc][Ii][Ii])echo OK;;*)echo KO;;esac
Code:
[[ "$data_type" = [Aa][Ss][Cc][Ii][Ii] ]]&&echo OK||echo KO
Reply With Quote
  #4 (permalink)  
Old 02-13-2007
Registered User
 

Join Date: Jan 2007
Posts: 364
data_type=`echo $data_type | tr '[a-z]' '[A-Z]'`
if [ "$data_type" == "ASCII" ]
Reply With Quote
  #5 (permalink)  
Old 02-14-2007
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,158
With ksh you can declare a variable with the attribute 'contains always uppercase' :
Code:
typeset -u UpperVar
UpperVar='AbCdEf'
echo $UpperVar   # -> Ouput is : ABCDEF
In the same way you can use the -l option for lowercase contents.

jean-Pierre.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0