![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash recursive scripting | James McMurray | Shell Programming and Scripting | 8 | 2 Weeks Ago 04:19 PM |
| Log FILES in BASH scripting | jackdaw | Shell Programming and Scripting | 2 | 12-05-2007 01:25 PM |
| Bash shell Scripting help | keyvan | Shell Programming and Scripting | 0 | 05-15-2007 03:36 PM |
| Help!! bash shell scripting.. | Fr0z3n999 | Shell Programming and Scripting | 1 | 12-07-2006 01:08 PM |
| bash shell scripting | azazalis | Shell Programming and Scripting | 4 | 07-11-2006 12:22 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Bash Scripting
Hello there peeps:
There is a little piece of bash shell scripting problem i have, which i was hoping you could help me with. Code:
#!/bin/bash
stored_word()
{
case $(( $$ % 8 )) 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 "advertisement" ;;
#11 ) echo "heading" ;;
#12 ) echo "distasteful" ;;
#13 ) echo "fashioned" ;;
#14 ) echo "variation" ;;
#15 ) echo "individual"
esac
}
Code:
word=$(stored_word)
letters=$(echo $word | wc -c)
letters=$(( $letters - 1 ))
template="$(echo $word | tr '[a-z A-Z 0-9]' '.')"
remaining=$letters
Simply what i am trying to achieve is, for the function stored_word to generate a random word and then insert it into $word, which dose. then the 2nd piece of code, mixes it all up. The main problem is they are in the same script and need to be in 2 different script. How can i achieve that, without using sed or awk? Keyvan |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
. stored_word_script
word=$(stored_word)
letters=$(echo $word | wc -c)
letters=$(( $letters - 1 ))
template="$(echo $word | tr '[a-z A-Z 0-9]' '.')"
remaining=$letters
|
|
#3
|
|||
|
|||
|
Quote:
Keyvan |
|
#4
|
|||
|
|||
|
Quote:
Code:
case $(( $RANDOM % 8 )) in |
|||
| Google The UNIX and Linux Forums |