#!/bin/bash let FILECOUNT=$RANDOM%`ls | wc -l`; # echo $RANDOM%$FILECOUNT for i in $(ls); do if [ $FILECOUNT -gt 1 ]; then let FILECOUNT-=1; else file $i >/dev/null echo $i >/dev/null cd $i 2>/dev/null if [ $? -eq 0 ]; then $0; else echo `pwd`"/"$i fi exit; fi done