[NTLUG:Discuss] Bash script question

MikeP palazzini at comcast.net
Wed Jan 19 18:25:42 CST 2005


Lance Simmons wrote:

>Let's say I have 100 names in a file.  I want to randomly select a name
>from the file, add it to a list, and repeat that process 40 times.  The
>result of the process should be a list of 40 names in random order, some
>of which may repeat in the list.
>
>What I've been doing up to now is putting the 100 names in random order
>and then taking the first 40 lines of the resulting list.  But I want to
>have the possibility of a name appearing multiple times on the same
>list.
>
>Does anyone have any suggestions?
>
>  
>
Nested loop with a variable for a name that repeats.  Ex: varSameName.  
Then an "if-then-else" statement or some other control statement to list 
name more than once.

"The Net, the personal computer, and softwore such as the Linux 
operating system--were actually developed not by enterprises or 
governments but were created primarily by some enthusiastic individuals, 
who just started to realize their ideas with other like-minded 
individuals working in a free rhythm." The Hacker Ethic by Pekka 
Himanen, Linus Torvalds, and Manuel Castells. 2001



More information about the Discuss mailing list