The UNIX and Linux Forums  


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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
$random relle Shell Programming and Scripting 6 07-11-2008 06:59 AM
Random command melaz Shell Programming and Scripting 1 07-10-2008 09:24 PM
FTP random files whegra Shell Programming and Scripting 3 11-21-2007 05:22 PM
Getting a random file davidY Shell Programming and Scripting 6 01-01-2007 05:03 AM
random in ksh pascalbout AIX 1 01-04-2006 10:53 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-24-2007
keyvan keyvan is offline
Registered User
  
 

Join Date: May 2007
Posts: 14
Random

My problem is as follow and i hope you can help:

I currently have this function:


Code:

stored_word()
{
number=$RANDOM
let "number %= 21"
case $number in
0 ) echo "energy"    ;;  1 ) echo "touch" ;;
2 ) echo "climbing" ;;   3 ) echo "declare" ;;
4 ) echo "marry"  ;;     5 ) echo "relax"   ;;
6 ) echo "bugs"     ;;   7 ) echo "inaccessible" ;;
8 ) echo "country" ;;    9 ) echo "folder" ;;
10 ) echo "individual" ;; 11 ) echo "youngest" ;;
12 ) echo "disco" ;; 13 ) echo "disturbed" ;;
14 ) echo "company" ;; 15 ) echo "scientific" ;;
16 ) echo "disaster" ;; 17 ) echo "protection" ;;
18 ) echo "curiously" ;; 19 ) echo "deranging" ;;
21 ) echo "facilities"

esac
 }

then i recalled it using the Dot command suggested here into my script as follow:


Code:
        . hangman_words
        word=$(stored_word)
        letters=$(echo $word | wc -c)
        letters=$(( $letters - 1 ))
        template="$(echo $word | tr '[a-z A-Z 0-9]' '.')"
        remaining=$letters

works fine, but the words should not be in a function or hard coded... and tbh i am not what i need to do, to create a word randomly, and sed and awk are out of question as well.

Can any one shed a light on this please?

K
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0