The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: Random
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 05-24-2007
keyvan keyvan is offline
Registered User
  
 

Join Date: May 2007
Posts: 14
Quote:
Originally Posted by anbu23
Code:
no=$(( RANDOM % 21 + 1 ))
while read str
do
	(( no = no - 1 ))
	if [[ $no -eq 0 ]]; then
		word=$str
		break
	fi
done < words_list_file 
letters=$(echo $word | wc -c)
letters=$(( $letters - 1 ))
template="$(echo $word | tr '[a-z A-Z 0-9]' '.')"
remaining=$letters
am i correct to assume that the above script will produce a random word, as long as the words are set as follow:

[TEXT]
word1
word2
word3
word4
etc..
[/TEXT]

K