using /usr/bin/cut in scripts...

Dave Turner dmt at PacBell.COM
Tue Jul 31 05:11:12 AEST 1990


In article <19253 at well.sf.ca.us> whofan at well.sf.ca.us (Brian Lawrence Dear) writes:
.The following is a portion of an installation script.  This portion
.reads the /etc/group file, figures out what's the next available
.group ID, and then creates a new group and assigns it that next
.available ID number:
. 
.          gid=`/usr/bin/cut -f3 -d: /etc/group|sort -n|tail -1`
.          gid=`eval $gid + 1`
.          echo "mygroup::$gid:user1,user2,usern" >> /etc/group
. 

If you have sed, you could replace line one above with:

	gid=`sort -t: -rn +2 -3 /etc/group | sed -n -e "1s/.*:.*:\(.*\):.*/\1/p"`



-- 
Dave Turner	415/823-2001	{att,bellcore,sun,ames,decwrl}!pacbell!dmt



More information about the Comp.unix.xenix mailing list