Sponsored Content
Full Discussion: randomization
Top Forums Shell Programming and Scripting randomization Post 302117718 by keyvan on Wednesday 16th of May 2007 06:18:12 AM
Old 05-16-2007
randomization

I have two files:


First file with 10 words, as follow:

randomword1, randomword2, randomword3, randomword4, etc...

Second File shell script.
Code:
word=$(cat hangman_words | cut -d" " -f1)
letters=$(echo $word | wc -c)
letters=$(( $letters - 1 ))
echo $letters
echo $word

The script above will give always give me the first word in the file. I need it to choose a random one each time.

how can i randomly choose a diffrent one everytime i run a script. Hopefully with out using sed or awk.

thx in advance

K

Last edited by keyvan; 05-16-2007 at 09:17 AM.. Reason: Additional Information
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

Randomization a matrix - perl / Shell

Hello all, I have a tricky question! (at least for me it is!). I'll try to explain it carefully here. Hope you can help me solving the whole or even parts of it! Here it is: I have a big input 0\1 table as a very simplified one is shown below: (The last row and column are the sum and... (0 Replies)
Discussion started by: @man
0 Replies
BOGGLE(6)							   Games Manual 							 BOGGLE(6)

NAME
boggle - play the game of boggle SYNOPSIS
/usr/games/boggle [ + ] [ ++ ] DESCRIPTION
This program is intended for people wishing to sharpen their skills at Boggle (TM Parker Bros.). If you invoke the program with 4 argu- ments of 4 letters each, (e.g. "boggle appl epie moth erhd") the program forms the obvious Boggle grid and lists all the words from /usr/dict/words found therein. If you invoke the program without arguments, it will generate a board for you, let you enter words for 3 minutes, and then tell you how well you did relative to /usr/dict/words. The object of Boggle is to find, within 3 minutes, as many words as possible in a 4 by 4 grid of letters. Words may be formed from any sequence of 3 or more adjacent letters in the grid. The letters may join horizontally, vertically, or diagonally. However, no position in the grid may be used more than once within any one word. In competitive play amongst humans, each player is given credit for those of his words which no other player has found. In interactive play, enter your words separated by spaces, tabs, or newlines. A bell will ring when there is 2:00, 1:00, 0:10, 0:02, 0:01, and 0:00 time left. You may complete any word started before the expiration of time. You can surrender before time is up by hitting 'break'. While entering words, your erase character is only effective within the current word and your line kill character is ignored. Advanced players may wish to invoke the program with 1 or 2 +'s as the first argument. The first + removes the restriction that positions can only be used once in each word. The second + causes a position to be considered adjacent to itself as well as its (up to) 8 neighbors. 4th Berkeley Distribution May 20, 1985 BOGGLE(6)
All times are GMT -4. The time now is 04:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy