Xref: utzoo comp.unix.wizards:23190 comp.unix.i386:7371 comp.unix.xenix:12602 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!pacbell.com!pacbell!ptsfa!dmt From: dmt@PacBell.COM (Dave Turner) Newsgroups: comp.unix.wizards,comp.unix.i386,comp.unix.xenix Subject: Re: using /usr/bin/cut in scripts... Keywords: cut, shell scripts Message-ID: <5342@ptsfa.PacBell.COM> Date: 30 Jul 90 19:11:12 GMT References: <19253@well.sf.ca.us> Reply-To: dmt@PacBell.COM (Dave Turner) Followup-To: comp.unix.wizards Organization: Pacific * Bell, San Ramon, CA Lines: 19 In article <19253@well.sf.ca.us> whofan@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