Sh scripting: Iterate through all ASCII chars

# ascii for A starts at 65:
ascii=65
index=1
total=26
while [[ $total -ge $index ]]
do
    letter=$(echo "$ascii" | awk '{ printf("%c", $0); }')
    echo "The $index'th letter is $letter"

    # Increment the index counter as well as the ascii counter
    index=$((index+1))
    ascii=$((ascii+1))
done

Reference:

Bash script. Iterate through all ASCII chars




Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>