databuild/examples/basic_graph/execute.sh

19 lines
No EOL
570 B
Bash
Executable file

#!/bin/bash
# Generate a random number based on the partition ref
# $1 is the partition ref (output path)
# Create a hash of the partition ref to use as a seed
SEED=$(echo "$1" | md5sum | awk '{print $1}')
# Convert the hex hash to a decimal number (using the first 8 characters)
SEED_DEC=$((16#${SEED:0:8}))
# Set the random seed
RANDOM=$SEED_DEC
# Generate a random number
RANDOM_NUMBER=$RANDOM
# Write the random number to the output file
echo "Random number for partition $1: $RANDOM_NUMBER" > "$1"
echo "Generated random number $RANDOM_NUMBER for partition $1"