Skip to content

Commit

Permalink
Add randline
Browse files Browse the repository at this point in the history
  • Loading branch information
sinecode committed Oct 8, 2019
1 parent 678389d commit 0bb97b9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -76,3 +76,9 @@ To disable hyper-threading run:
To enable hyper-threading run:

$ sudo set-hyper-threading 1

### randline

Bash script to print a random line of a file.

$ randline <filename>
25 changes: 13 additions & 12 deletions bin/clitesseract
@@ -1,23 +1,24 @@
#!/bin/bash


function main {
# Execute tesseract command, display the output of the generated file and delete it
tesseract $1 /tmp/clitess_out "${@:2}"
cat /tmp/clitess_out* 2> /dev/null
rm /tmp/clitess_out* 2> /dev/null
# Execute tesseract command, display the output of the generated file and delete it
tesseract $1 /tmp/clitess_out "${@:2}"
cat /tmp/clitess_out* 2> /dev/null
rm /tmp/clitess_out* 2> /dev/null
}

function showHelp {
echo "Tesseract command line tool."
echo ""
echo "Display the output of a Tesseract execution without worry of the output file"
echo ""
echo "Usage:"
echo " clitesseract <imagename> [OPTIONS] [CONFIGURATIONS]"
echo "Tesseract command line tool."
echo ""
echo "Display the output of a Tesseract execution without worry of the output file"
echo ""
echo "Usage:"
echo " clitesseract <imagename> [OPTIONS] [CONFIGURATIONS]"
}

if [ $1 = "--help" ] || [ $1 = "-h" ]; then
showHelp
showHelp
else
main "$@"
main "$@"
fi
11 changes: 11 additions & 0 deletions bin/randline
@@ -0,0 +1,11 @@
#!/bin/bash


if [ ! -f "$1" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "Usage: randline <filename>"
echo ""
echo "Display a random line of a file"
exit -1
fi

sed -n $((RANDOM % $(wc -l "$1" | cut -d ' ' -f 1) + 1))p "$1"

0 comments on commit 0bb97b9

Please sign in to comment.