Last active
July 5, 2021 19:02
-
-
Save avdi/699a6a9f86c25d5012d3310db17f764a to your computer and use it in GitHub Desktop.
Pick a random file using Bash (on a mac)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $# -lt 1 ]]; then | |
echo "Usage: $0 somedir/*.jpg" | |
exit 1 | |
fi | |
files=($*) | |
let "i = $RANDOM % ${#files[*]}" | |
pick=${files[$i]} | |
echo "Draw: $pick" | |
open $pick |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment