home Mail List
Info
Info
Meetings
Goals
Upcoming
Projects
FAQ
Security
Links

[Date Prev][Date Next] [Chronological] [Thread] [Top]

[NMLUG] grep help



On Wed, 2005-03-16 at 15:40 -0700, Jason Davis wrote:
> On Wed, 2005-03-16 at 14:39 -0700, Ed Heron wrote:
> >   I'm writing a bash script that needs to check if a particular person is in 
> > a specific group.
> > 
> >   I'm using:
> > 
> > if grep "^${group}:.*[:,]${user}[,$]" /etc/group >/dev/null ; then echo 
> > "${user} is a member of ${group}" ; fi
> > 
> >   Unfortunately, if $user is last in the list it appears to be false.  If I 
> > `grep "^${group}:.*[:,]${user}$" /etc/group` it succeeds.
> > 
> >   I don't use many regexp, am I missing something? 
> > 
> 
> 
> 
> this works for me
> 
> if grep -R "audio.*,*fred,*" /etc/group > /dev/null; then echo "yes"; fi
> 

er ... forget the -R part , dont know what i was doing

jd


> 
> 
> 
> > _______________________________________________
> > NMLUG mailing list
> > NMLUG@nmlug.org
> > http://www.nmlug.org/mailman/listinfo/nmlug
> 
> _______________________________________________
> NMLUG mailing list
> NMLUG@nmlug.org
> http://www.nmlug.org/mailman/listinfo/nmlug




Please send sugestions and comments to webmaster@nmlug.org.
Valid XHTML 1.1! Valid CSS! Powered by Debian Powered by Apache