Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8757511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:19:09+00:00 2026-06-13T14:19:09+00:00

I know how to iterate through alphabets: for c in {a..z}; do …; done

  • 0

I know how to iterate through alphabets:

for c in {a..z}; do ...; done

But I can’t figure out how to iterate through all ASCII characters. Does anyone know how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:19:10+00:00Added an answer on June 13, 2026 at 2:19 pm

    What you can do is to iterate from 0 to 127 and then convert the decimal value to its ASCII value(or back).

    You can use these functions to do it:

    # POSIX
    # chr() - converts decimal value to its ASCII character representation
    # ord() - converts ASCII character to its decimal value
    
    chr() {
      [ ${1} -lt 256 ] || return 1
      printf \\$(printf '%03o' $1)
    }
    
    # Another version doing the octal conversion with arithmetic
    # faster as it avoids a subshell
    chr () {
      [ ${1} -lt 256 ] || return 1
      printf \\$(($1/64*100+$1%64/8*10+$1%8))
    }
    
    # Another version using a temporary variable to avoid subshell.
    # This one requires bash 3.1.
    chr() {
      local tmp
      [ ${1} -lt 256 ] || return 1
      printf -v tmp '%03o' "$1"
      printf \\"$tmp"
    }
    
    ord() {
      LC_CTYPE=C printf '%d' "'$1"
    }
    
    # hex() - converts ASCII character to a hexadecimal value
    # unhex() - converts a hexadecimal value to an ASCII character
    
    hex() {
       LC_CTYPE=C printf '%x' "'$1"
    }
    
    unhex() {
       printf \\x"$1"
    }
    
    # examples:
    
    chr $(ord A)    # -> A
    ord $(chr 65)   # -> 65
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to do this if I iterate through all of the characters
Know this might be rather basic, but I been trying to figure out how
I would like to know how to iterate through all the elements in a
I'm trying to figure out how to iterate through a .Net grouping using the
I know that I can iterate over an object's properties like this: for (property
I know you can not set a key value dynamically, but what about the
Anyone know how I can make a login button in Ruby on Rails for
I'd like to iterate through all the rows in a gridview and retrieve data
I'm trying to make a PHP (5) object that can iterate through its properties,
I want to iterate through all columns to find and replace a specific character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.