Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Nov 2000 21:16:51 -0600
From:      Dan Nelson <dnelson@emsphone.com>
To:        cjclark@alum.mit.edu
Cc:        Sue Blake <sue@welearn.com.au>, freebsd-questions@FreeBSD.ORG
Subject:   Re: unsorting
Message-ID:  <20001125211651.B6923@dan.emsphone.com>
In-Reply-To: <20001125143838.Z12190@149.211.6.64.reflexcom.com>; from "Crist J . Clark" on Sat Nov 25 14:38:38 GMT 2000
References:  <20001126023150.F377@welearn.com.au> <20001125143838.Z12190@149.211.6.64.reflexcom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Nov 25), Crist J . Clark said:
> On Sun, Nov 26, 2000 at 02:31:53AM +1100, Sue Blake wrote:
> > Is there some fairly simple way I can put a list of letters or
> > words, or lines of a text file, into a random order?
> 
> However, a really quick and ugly approach is to load the list into
> memory, then just step through it swapping each item with another in
> a random location. To be a little different, here is an awk(1) script
> that does it,

And just to be a bit more different, here's a shell script that will
randomize the contents of the filename passed on the commandline:

#! /bin/sh
jot -r $(wc -l < $1) 1 1000000 | paste - $1 | sort -n | cut -f2-

-- 
	Dan Nelson
	dnelson@emsphone.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001125211651.B6923>