mirror of
https://github.com/trueChristian/daily-scripture.git
synced 2025-01-24 21:08:24 +00:00
Adds more RANDOM
This commit is contained in:
parent
87b8a9595d
commit
dc5d24274c
@ -86,12 +86,14 @@ if [ -z "${TODAY_S_SCRIPTURE}" ]; then
|
||||
#████████████████████████████████████████████████████████████████ RANDOM ███
|
||||
# set a random temp file
|
||||
sort -R -k1 -b "${SORTED}" >"${TMP}"
|
||||
# get the first line
|
||||
TODAY_S_SCRIPTURE=$(head -n 1 "${TMP}")
|
||||
# get a random number between 1 and 1900
|
||||
RANDOM_LINE=$((RANDOM % 1900 + 1))
|
||||
# get the line corresponding to the random number
|
||||
TODAY_S_SCRIPTURE=$(sed -n "${RANDOM_LINE}{p;q}" "${TMP}")
|
||||
# only if not a test
|
||||
if (("$DRY_RUN" == 0)); then
|
||||
# remove the verse
|
||||
sed -i -e '1,1d' "${TMP}"
|
||||
sed -i -e "${RANDOM_LINE},${RANDOM_LINE}d" "${TMP}"
|
||||
# add to used verses
|
||||
[ -f "${USED}" ] && echo "$TODAY_S_SCRIPTURE" >>"${USED}" || echo "$TODAY_S_SCRIPTURE" >"${USED}"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user