Autosave: 2022-12-14 19:30:05

This commit is contained in:
thomasabishop 2022-12-14 19:30:05 +00:00
parent 5fd1b8cb32
commit d311f4835e

View file

@ -1,11 +1,17 @@
#!/bin/bash #!/bin/bash
# This script returns a random topic for me to revise
# Choose source directories...
DIRS_TO_PARSE="../Algorithms ../Computer_Architecture ../Databases" DIRS_TO_PARSE="../Algorithms ../Computer_Architecture ../Databases"
# Return array of all files belonging to source dirs...
for ele in $DIRS_TO_PARSE; do for ele in $DIRS_TO_PARSE; do
FILE_MATCHES+=( $(find $ele -name "*.md" -type f) ) FILE_MATCHES+=( $(find $ele -name "*.md" -type f) )
done done
# Generate a random integer between 0 and the match array length...
RANDOM_FILE_INDEX=$(( $RANDOM % ${#FILE_MATCHES[@]} + 0 )) RANDOM_FILE_INDEX=$(( $RANDOM % ${#FILE_MATCHES[@]} + 0 ))
# Return file matching that index...
echo "Revise this topic: ${FILE_MATCHES[$RANDOM_FILE_INDEX]}" echo "Revise this topic: ${FILE_MATCHES[$RANDOM_FILE_INDEX]}"