# Add this into your .bashrc file or something

function showsymbols {
    if [ ! -f "$1" ]; then
        echo "Usage: showsymbols <sample file>"
        return;
    fi
    echo "*" |p2re -i $1 |sed s/[\|\(\)\+\ ]//g
}

function maxlen {
    if [ ! -f "$1" ]; then
        echo "Usage: maxlen <sample file>"
        return;
    fi
    wc -L $1 |cut -d\  -f 1
}

function minlen {
    if [ ! -f "$1" ]; then
        echo "Usage: minlen <sample file>"
        return;
    fi
    L=10000
    for LINE in `cat $1`; do
        LEN=`echo $LINE |wc -L`
        if [ $LEN -lt $L ]; then
            L=$LEN
        fi
    done
    echo $L
}

function totlen {
    if [ ! -f "$1" ]; then
        echo "Usage: totlen <sample file>"
        return;
    fi
    expr `wc -m $1 |cut -d\  -f 1` - `wc -l $1 |cut -d\  -f 1`
}

function avglen {
    if [ ! -f "$1" ]; then
        echo "Usage: avglen <sample file>"
        return;
    fi
    TOTLEN=`totlen $1`
    TOTLINE=`wc -l $1 |cut -d\  -f 1`
    gawk "BEGIN{print $TOTLEN/$TOTLINE}"
}
