[NTLUG:Discuss] Bash script question

Paul Ingendorf pauldy at wantek.net
Thu Jan 20 08:44:21 CST 2005


Small OB1 error x % 100 = 0-99 = 100 possitions. What you want are 100
possitions starting with 1 easily solved with.
s=$(expr $RANDOM % 100 + 1)


-----Original Message-----
From: discuss-bounces at ntlug.org [mailto:discuss-bounces at ntlug.org]On
Behalf Of Lance Simmons
Sent: Wednesday, January 19, 2005 4:23 PM
To: discuss at ntlug.org
Subject: Re: [NTLUG:Discuss] Bash script question


* Chris Cox <cjcox at acm.org> [050119 15:19]:
>
> Off the top of my head (this is bash)
>
> file="$1"
> # Cheep seeding (good enough?)
> RANDOM=$(expr $(date +%d%S%M%S) % 32767)
> for (( i=1; i <= 40; i++)); do
> 	s=$(expr $RANDOM % 100)
> 	sed -n "${s}p" $file
> done

A noticeable percentage of the time, sed chokes on line address 0.

--
Lance Simmons
Culture survives and develops under the aegis of permanence.
 Instantaneity --
the enemy of permanence -- is one of the chief imperatives of our time. It
renders anything lasting, anything inherited, suspicious by definition.
		-- Roger Kimball

_______________________________________________
https://ntlug.org/mailman/listinfo/discuss




More information about the Discuss mailing list