find_special

Purpose: find the most special-character-dense lines of standard input.
Usage: find_special

Writes each line of stdin to stdout, sorted in descending order by the proportion of special characters in the line.

Download find_special

Changelog:
2022-235 initial development
2023-246 reformat/redocument a tad

Source code (perhaps slightly corrupted) is as follows.

IFS=''

while read -r A
do
    A=`echo -n "$A" | sed 's/^ +//g'`
    TOTAL=`echo -n "$A" | wc -c`
    if [ "$TOTAL" = 0 ]
    then
        continue
    fi
    SPECIAL=`echo -n "$A" | grep -Eo '[^ a-zA-Z0-9]' | wc -l`
    if [ "$SPECIAL" = 0 ]
    then
        continue
    fi
    printf "%d	%s
" "$(((1000*SPECIAL*SPECIAL)/(TOTAL-SPECIAL+1)))" "$A"
done | sort -nr | cut -f 2,

All scripts | dkl9 home