Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!oliveb!sun!limes From: limes@sun.uucp (Greg Limes) Newsgroups: comp.unix.questions Subject: Re: Unix shell prgrams and AI techniques Message-ID: <57517@sun.uucp> Date: 22 Jun 88 15:59:05 GMT References: <7387@watdragon.waterloo.edu> <514@philmds.UUCP> <133@quintus.UUCP> Reply-To: limes@sun.UUCP (Greg Limes) Organization: Sun Microsystems, Mountain View Lines: 33 In article <133@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >In article <514@philmds.UUCP> leo@philmds.UUCP (L.J.M. de Wit) writes: >:B.T.W. Testing this script I discovered what seems to be a bug in sort >:(Ultrix 2.0). >:The following two lines when fed into sort -u +15: >: Mon Jun 20 19:36 still logged inuucp ttyic >: Mon Jun 20 18:07 still logged inleo ttyid >:generate only one line: >: Mon Jun 20 19:36 still logged inuucp ttyic >:The manual says: A missing -num argument means the end of the line, >:and for u: Suppress all but one in each set of equal lines. Ignored bytes >:and bytes outside keys do not participate in the comparision. >:Am I wrong or is the manual wrong (or is sort buggy)? > >Trying "sort -u +15" with just these two records on a Sun-3/50 running >SunOS 3.2, I get as output whichever of the two records came first. >There are said to be problems with the -u option of sort, so I always >avoid it. "sort +15 | uniq" works fine. (Good thing my flame thrower is in the shop)] It works even better if you use +.15; that little dot between the plus sign and the one is kind of important. The general form is +f.c, where f is the number of fields to skip and c is the number of characters to skip. Beats me why you would want to skip either fifteen characters or fifteen fields above; if you wanted to start your sort at "still", I would use +4 instead. And yes, the -u option does precisely what the manual claims. In the above example, of course, all the keys were empty and therefore equal. Using "-u +4" would sort the records, leaving one line per login name per tty. -- Redhead [limes@sun.com] R.T.F.M.