The UNIX and Linux Forums  

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
max size of a group in /etc/group antalexi AIX 4 05-11-2008 10:01 AM
how i prepare a c++ code(c code) for implementing my own protocol format amitpansuria High Level Programming 1 09-07-2007 12:09 AM
Monkcast #12: IBM HW group OEMs Solaris to chagrin of SW group & a ... - ZDNet.com bl iBot UNIX and Linux RSS News 0 08-17-2007 05:30 PM
entry in /etc/group too long - problem using sudo with %group poli SUN Solaris 4 12-21-2004 09:50 AM
NIS group vs local group vjsony UNIX for Dummies Questions & Answers 3 05-19-2003 10:54 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 08-08-2001
Alan Bird Alan Bird is offline
Registered User
  
 

Join Date: Aug 2001
Location: Longview, Washington
Posts: 7
Question How do I code 'not in this group'

I am trying to find if the entered value is not in a group. Here is my code.

Code:
if [ $1 not in ( "LVCH", "LVEI", "LVMI", "LVCH" )  ]
  then
    echo 'Sid is not in list. Try one of these in caps.'
    echo 'LVCH,  LVEI, LVMI, LVCH'
    exit
fi;

Any Ideas?

added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 10:56 AM..
  #2 (permalink)  
Old 08-08-2001
ober5861's Avatar
ober5861 ober5861 is offline
Registered User
  
 

Join Date: Jul 2001
Location: Gettysburg, PA
Posts: 116
This probably isn't the shortest answer but here's one way:

Read in the variable and compare it, one at at time, to your groups. In other words, a nested if/else type of thing. But my guess is that you're trying to find a shortcut and have already thought of this method. If you find an answer before someone else gets back to you, please post it!

Also, I know you can do it with C, but just for comparisons sake, you may want to find a way to take your variable to caps or all to lower, (ie. toupper and tolower in C)
  #3 (permalink)  
Old 08-08-2001
Alan Bird Alan Bird is offline
Registered User
  
 

Join Date: Aug 2001
Location: Longview, Washington
Posts: 7
From another dba I work with.


Code:
case $1 in
	"LVCH"|"LVEI"|"LVMI"|"LVCH") ;;
	*) echo 'Sid is not in list. Try one of these in caps.'
	   echo 'LVCH,  LVEI, LVMI, LVCH'
	   exit ;;
esac



added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 10:56 AM..
  #4 (permalink)  
Old 08-08-2001
Alan Bird Alan Bird is offline
Registered User
  
 

Join Date: Aug 2001
Location: Longview, Washington
Posts: 7
Another answer


Code:
if [ $1 != "LVCH" ]
then    
        if [ $1 != "LVEI" ]
        then
                if [ $1 != "LVMI" ]
                then
                        if [ $1 != "LVCH" ]
                        then
                              echo 'Sid is not in list.'
                              echo 'Try one of these in caps.'
                              echo 'LVCH,  LVEI, LVMI, LVCH'
                              exit
                        fi
                fi
        fi
fi;



added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 10:57 AM..
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 11:15 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