pullline.sh 487 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # copyright (c) 2013 jeff cliff
  3. # this file is licensed under the GNU GPLv3 or at your option any later version
  4. # see COPYING.GPL
  5. file -E $1 >/dev/null
  6. if [[ $? -eq "1" ]]; then
  7. echo "file doesnt exist"
  8. exit 1;
  9. #else
  10. # echo "...exists"
  11. fi
  12. DICE=`wc -l $1 | awk -F' ' '{print $1}'`
  13. # echo $DICE
  14. NUMBER=`rolldice 1d$DICE`
  15. # echo $NUMBER
  16. NUMBER1=$NUMBER"p"
  17. # echo $NUMBER1
  18. sed -n $NUMBER1 $1
  19. # if this ever doesnt work the next thing to investigate is gnu 'shuf'