IsraelTorres

fstring.sh

Feb 8th, 2012
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # ./fstring.sh
  3. # factor string and fold factored output
  4. # Israel Torres
  5. # Wed Feb  8 07:34:42 PST 2012
  6. #
  7. rqdapp='factor'
  8. hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - aborting"; exit 1; }
  9. #
  10. if [ ! $# -lt 1 ]; then
  11.     fme=$(echo -n $1 | wc -c)
  12.     fct=$($rqdapp $fme)
  13.     echo -e "LENGTH:"$fme
  14.     echo -e "FACTOR:\t$fct"
  15.     for i in ${fct}; do
  16.         fout=$(echo $1 | fold -$i)
  17.         echo -en "#$i#\t"
  18.         for x in {1..72}; do
  19.             echo -n "#"
  20.         done
  21.         echo -e "$fout\n"
  22.     done
  23. else
  24. echo "usage: $0 'string'"
  25. echo "example: $0 string"
  26. fi
RAW Paste Data