Move under www to ease rsync
This commit is contained in:
25
www/eps/hpr2699/hpr2699_bash15_ex1.sh
Executable file
25
www/eps/hpr2699/hpr2699_bash15_ex1.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Example 1 for Bash Tips show 15 - a working example similar to clacke's
|
||||
# problem example in the comments to HPR episode 2651
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Initialise an array
|
||||
#
|
||||
items=()
|
||||
|
||||
#
|
||||
# Populate the array with random words
|
||||
#
|
||||
while read -r item; do
|
||||
items+=( "$item" )
|
||||
done < <(grep -E -v "'s$" /usr/share/dict/words | shuf -n 5)
|
||||
|
||||
#
|
||||
# Print the array with word numbers
|
||||
#
|
||||
for ((i = 0, j = 1; i < ${#items[@]}; i++, j++)); do
|
||||
echo "$j: ${items[$i]}"
|
||||
done
|
||||
Reference in New Issue
Block a user