Skip to content

Instantly share code, notes, and snippets.

@JanVoracek
Created July 21, 2011 08:51
Show Gist options
  • Save JanVoracek/1096809 to your computer and use it in GitHub Desktop.
Save JanVoracek/1096809 to your computer and use it in GitHub Desktop.
Get random file (recursive)
#!/bin/bash
files=($(find $1 -type f -printf "%f\r\n"))
num_files=${#files[*]}
echo "${files[$((RANDOM%num_files))]}"
$ ./random_book.sh [directory]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment