Save as 'dirrand2'


SUBMITTED BY: Guest

DATE: Feb. 23, 2013, 10:54 p.m.

FORMAT: Bash

SIZE: 408 Bytes

HITS: 1593

  1. #!/bin/bash
  2. let FILECOUNT=$RANDOM%`ls | wc -l`;
  3. # echo $RANDOM%$FILECOUNT
  4. for i in $(ls); do
  5. if [ $FILECOUNT -gt 1 ]; then
  6. let FILECOUNT-=1;
  7. else
  8. file $i >/dev/null
  9. echo $i >/dev/null
  10. cd $i 2>/dev/null
  11. if [ $? -eq 0 ]; then
  12. dirrand2;
  13. else
  14. echo `pwd`"/"$i
  15. fi
  16. exit;
  17. fi
  18. done

comments powered by Disqus