- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help with LIKE operator or $GROUP variable
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 05:07 AM
тАО11-03-2004 05:07 AM
if [ "$LOGNAME" = "user1"]
I'd like to change this to either
"$GROUPNAME =" OR "$LOGNAME like".
Thanks for any assistance,
Staci
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 05:14 AM
тАО11-03-2004 05:14 AM
Re: Help with LIKE operator or $GROUP variable
GROUP = `groups $LOGNAME |awk '{print $1}'`
if [ "$GROUP" = "adm"]
...etc
Rgds...Geoff
- Tags:
- groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 05:29 AM
тАО11-03-2004 05:29 AM
Re: Help with LIKE operator or $GROUP variable
case "$(id -gn)" in
(grp1) ... ;;
(grp2) ... ;;
esac
If you need to look at all of the user's groups, then `groups` would be more appropriate.
for g in $(groups); do
case "$g" in
(grp1) ... ;;
(grp2) ... ;;
esac
done
For simple matching of similar usernames, like user123, user124, etc, try this:
if [ "${LOGNAME%[0-9][0-9][0-9]}" == "user" ]
or
case "$LOGNAME" in
(user*) ... ;;
(*tst) ... ;;
([a-z][0-9]admin?) ... ;;
esac
- Tags:
- id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 05:41 AM
тАО11-03-2004 05:41 AM
Solutiongroups -p $LOGNAME
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 10:57 AM
тАО11-03-2004 10:57 AM
Re: Help with LIKE operator or $GROUP variable
GROUP = $(groups -d $LOGNAME)
if [$GROUP=support]
then ...
Staci
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 11:26 AM
тАО11-03-2004 11:26 AM
Re: Help with LIKE operator or $GROUP variable
Don't just thank them... give them some points! :-).
>> The one that worked best for my situation was : GROUP = $(groups -d $LOGNAME)
Uh.... that's a typo right? -d really is -p.
btw... if you are really concerned about a user being part of multipel groups (root), then you may want to try something like:
if groups $LOGNAME | grep -q support ; then echo "yes"; else echo "no"; fi
Cheers,
Hein.