IsraelTorres icon

fstring.sh

IsraelTorres | PRO | 02/08/12 02:43:48 PM UTC | 0 ⭐ | 436 👁️ | Never ⏰ | []
Bash |

610 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
# ./fstring.sh
# factor string and fold factored output
# Israel Torres
# Wed Feb  8 07:34:42 PST 2012
#
rqdapp='factor'
hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - aborting"; exit 1; }
#
if [ ! $# -lt 1 ]; then
    fme=$(echo -n $1 | wc -c)
    fct=$($rqdapp $fme)
    echo -e "LENGTH:"$fme 
    echo -e "FACTOR:\t$fct"
    for i in ${fct}; do
        fout=$(echo $1 | fold -$i)
        echo -en "#$i#\t"
        for x in {1..72}; do
            echo -n "#"
        done
        echo -e "$fout\n"
    done
else
echo "usage: $0 'string'"
echo "example: $0 string"
fi

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎