The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help to delete brackets [ ] kamel.seg Shell Programming and Scripting 4 01-18-2008 11:53 AM
why put double square brackets in an if clause? napolayan UNIX for Dummies Questions & Answers 5 11-16-2006 03:18 AM
how do you use brackets ?? in a script. moxxx68 Shell Programming and Scripting 3 09-27-2004 11:57 PM
square brackets gilead29 UNIX for Dummies Questions & Answers 2 02-03-2004 11:29 AM
Angle brackets PxT Post Here to Contact Site Administrators and Moderators 1 04-05-2001 07:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-27-2006
lakshmikanth lakshmikanth is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 6
usage of brackets for if

Hi,

I would like to know about the usage of brackets to negate a set of boolean evaluations
an equivalent to what i am trying is below

if [ ! [ [$INPUT=="Morning"] or [$INPUT=="Evening"] || [$INPUT=="Night"] ] ]
then
echo"valid time of day"
else
echo "invalid input"
exit
fi

the bracket structue as mentioned doesnt work .. i am using ksh. Please help.
Thanks a dozen. hoping for a quick reply .
  #2 (permalink)  
Old 07-27-2006
lakshmikanth lakshmikanth is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 6
The below code works

if ! (( [ ${TIME_OF_DAY} = "MORNING" ] ) || ( [ ${TIME_OF_DAY} = "AFTERNOON" ]) || ([ ${TIME_OF_DAY} = "EVENING" ] ) || ( [ ${TIME_OF_DAY} = "NIGHT" ]))

Thanks
  #3 (permalink)  
Old 07-27-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,122
Code:
if [[ $input != @(Morning|Evening|Night) ]] ; then
        echo fumble
fi
  #4 (permalink)  
Old 07-27-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2006
Posts: 360
Look at http://www.tldp.org/LDP/abs/html/tests.html
This is for bash, but I think it is also appropriate for ksh (At leas this gives good understanding of tests in shell scripts)
  #5 (permalink)  
Old 07-28-2006
lakshmikanth lakshmikanth is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 6
Thanks Guys. I got the idea .
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0