From d311f4835ead6979ed5fe0e413a18959fa5cd496 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Wed, 14 Dec 2022 19:30:05 +0000 Subject: [PATCH] Autosave: 2022-12-14 19:30:05 --- _scripts/random_revision_topic.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/_scripts/random_revision_topic.sh b/_scripts/random_revision_topic.sh index 3e4b4b9..fddd649 100755 --- a/_scripts/random_revision_topic.sh +++ b/_scripts/random_revision_topic.sh @@ -1,11 +1,17 @@ #!/bin/bash +# This script returns a random topic for me to revise + +# Choose source directories... DIRS_TO_PARSE="../Algorithms ../Computer_Architecture ../Databases" +# Return array of all files belonging to source dirs... for ele in $DIRS_TO_PARSE; do FILE_MATCHES+=( $(find $ele -name "*.md" -type f) ) done +# Generate a random integer between 0 and the match array length... RANDOM_FILE_INDEX=$(( $RANDOM % ${#FILE_MATCHES[@]} + 0 )) -echo "Revise this topic: ${FILE_MATCHES[$RANDOM_FILE_INDEX]}" +# Return file matching that index... +echo "Revise this topic: ${FILE_MATCHES[$RANDOM_FILE_INDEX]}" \ No newline at end of file