
# number of random generated words depends on supplied argument Non_random_words=`cat $ALL_NON_RANDOM_WORDS | wc -l` # total number of non-random words available random-word-generator 3" 1>&2Įcho "This will generate 3 random words" 1>&2ĪLL_NON_RANDOM_WORDS=/usr/share/dict/words Note: If you have your own source of random words, you can enter it by altering the constant variable ALL_NON_RANDOM_WORDS.Ĭreate a new script and paste the following code into it: #!/bin/bashĮcho "Please specify how many random words would you like to generate !" 1>&2Įcho "example.

As a last step, the previously randomly generated number will be used by the sed command to print a line corresponding with a random number generated previously. Next, it will generate a random number in range from 0 to total number words available.ģ. The random word generator script first gets the total number of words available in the /usr/share/dict/words file.Ģ. Here is how this random word generator works:ġ. This file should be available on all modern Linux operating systems. The following Vash random word generator uses /usr/share/dict/words as word input (feel free to use your own). $ – requires given linux commands to be executed as a regular non-privileged user # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command Privileged access to your Linux system as root or via the sudo command. Requirements, Conventions or Software Version Used Random Word Generator Software Requirements and Linux Command Line Conventions Category How to execute the random word generator script.How to create a random word generator with Bash on Linux.We will give you the code that you need for the script, and show you how to run it. In this tutorial, you will see how to make a Bash script that can generate any number of random words on a Linux system.


However, if you need to generate more words or automate your task, the Linux Bash shell can be a handy friend. If you need a single word, the easiest way is to visit an online Random Word Generator website. Random words can be used to set a new password or simply to create a bunch of randomly named directories. Sometimes a Linux user can be in need of a random word generator.
