Skip to content

Instantly share code, notes, and snippets.

@PicciMario
Created January 13, 2011 15:46
Show Gist options
  • Select an option

  • Save PicciMario/778071 to your computer and use it in GitHub Desktop.

Select an option

Save PicciMario/778071 to your computer and use it in GitHub Desktop.
Prints the name of a random file in the current directory
# Prints the name of a random file in the current directory
#! /bin/bash
set -- *
length=$#
random_num=$(( $RANDOM % ($length + 1) ))
echo ${!random_num}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment