Move under www to ease rsync
This commit is contained in:
35
www/eps/hpr2719/hpr2719_bash17_ex2.sh
Executable file
35
www/eps/hpr2719/hpr2719_bash17_ex2.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Example 2 for Bash Tips show 17: Array concatenation
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Make three indexed arrays
|
||||
#
|
||||
declare -a a1 a2 a3
|
||||
|
||||
#
|
||||
# Seed the random number generator
|
||||
#
|
||||
RANDOM=$(date +%N)
|
||||
|
||||
#
|
||||
# Place 10 random numbers between 1..100 into the arrays a1 and a2
|
||||
#
|
||||
for ((i=1; i<=10; i++)); do
|
||||
a1+=( $(( ( RANDOM % 100 ) + 1 )) )
|
||||
a2+=( $(( ( RANDOM % 100 ) + 1 )) )
|
||||
done
|
||||
|
||||
#
|
||||
# Show the results
|
||||
#
|
||||
echo "a1: ${a1[*]}"
|
||||
echo "a2: ${a2[*]}"
|
||||
|
||||
#
|
||||
# Concatenate a1 and a2 into a3 and show the result
|
||||
#
|
||||
a3=( "${a1[@]}" "${a2[@]}" )
|
||||
echo "a3: ${a3[*]}"
|
||||
Reference in New Issue
Block a user