SUMMARY: Help on egrep/regular expression

From: Sabrina Lautier <slautier_at_amadeus.net>
Date: Thu Jun 24 2004 - 12:18:01 EDT
Thanks to all who helped !

The most appropriate response for my need was the following one:
egrep ":##.*:$uid:" ${NIS_PATH}/passwd

grep/egrep use "." for the global charactor and "*" as zero or more of.

Regards,
Sabrina
----- Forwarded by Sabrina Lautier/NCE/AMADEUS on 24/06/2004 18:14 -----

From:  Sabrina Lautier <slautier@amadeus.net>@sunmanagers.org  on
       24/06/2004 16:12 ZE2

Sent by:    sunmanagers-bounces@sunmanagers.org


                                                                          
 To:    sunmanagers@sunmanagers.org                                       
                                                                          
                                                                          
 cc:                                                                      
                                                                          
                                                                          
                                                                          
                                                                          
                                                                          
                                                                          
 Subjec Help on egrep/regular expression                                  
 t:                                                                       
                                                                          
                                                                          
                                                                          





Dear Admin,

I'm writing a script whose goal is to find a free uid in NIS secure passwd
file.

The passwd file syntax is the following one:
username:##username:uid:gid:...

I was thinking about using egrep:
------------------------------------------------------------------------
# Starting with uid 5010
uid=5010

# Looking for a free user uid in NIS passwd file
rep=`egrep ':'$uid':' ${NIS_PATH}/passwd`
while [ "$rep" != "" ]
do
  let uid+=1
  rep=`egrep ':'$uid':' ${NIS_PATH}/passwd`
done
echo "User user id "$uid" can be used..."

exit 0
------------------------------------------------------------------------

This works fine except that regular expression ':'$uid':' can also match
gid...
What I would like to do is egrep ':##*'$uid':' ${NIS_PATH}/passwd but this
doesn't work.

Do you know a way to do that ?

Thanks in advance for your help.

Regards,

Sabrina Lautier
Amadeus SAS
DEV-IIS-OAU-SYS
+33 (0)4 97 23 09 56
slautier@amadeus.net
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Thu Jun 24 12:18:53 2004

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:32 EST