SHARE
TWEET

Untitled

a guest Oct 9th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env zsh
  2.  
  3. # FIXME: This script is noticeably slow, but scales linearly in the number of
  4. # words. Also the random selection is with replacement, and important feature
  5. # of generating English sentences
  6.  
  7. usage() {
  8.     cat << EOF
  9. Gerate place holder text from actual english words. The usage below would create
  10. a sentace with <n> words.
  11.  
  12. Usagee: ./lorem.zsh <n>
  13.  
  14. To specify location of the dictionary of words:
  15.  
  16. DICTIONARY_FILE=/custom/dict/path/wods ./lorem.zsh <n>
  17. EOF
  18. exit 1
  19. }
  20.  
  21. DICTIONARY_FILE="/usr/share/dict/words"
  22.  
  23. lorem() {
  24.     local nwords="$1"
  25.     sed -E 's/^(.)(.*)( )$/\U\1\2./' <(repeat "${nwords}"  echo -n "$(shuf -n 1 ${DICTIONARY_FILE}) ")
  26. }
  27.  
  28. [ "$#" -eq 1 ] || usage "Wrong argument count"
  29. lorem "$@"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top