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 7006609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:29:57+00:00 2026-05-27T21:29:57+00:00

Believe it or not, I can’t find the answer to what I would think

  • 0

Believe it or not, I can’t find the answer to what I would think would be this very basic question.

In awk, how can I loop over the input string character by character? Let’s say I just wanted to print them out. Is there an array I can access? Or do I need to use substr?

Basically, something like:

echo "here is a string" | awk '
{ for(i=0; i<[length of input string]; i++) 
    printf [value at index i in array x]; 
}'

Frankly, I’m embarrassed.

  • 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-05-27T21:29:57+00:00Added an answer on May 27, 2026 at 9:29 pm

    You can convert a string to an array using split:

    echo "here is a string" | awk '
    { 
      split($0, chars, "")
      for (i=1; i <= length($0); i++) {
        printf("%s\n", chars[i])
      }
    }'
    

    This prints the characters vertically, one per line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok this question stems from this question: wp7: App failing! Can not figure out
I've searched Google and this website many times, but can not find a solution
First of all, I do not believe this belongs on Superuser. This belongs here
Despite working on EE for about 3 weeks now, believe it or not, this
This is a bit of an open question but I would really like to
This should be a fairly simple question. Essentially, I believe there's a good chance
I have been working on this form for my php class. I can not
I'm sorry for such a silly question, but I can not fathom the name
Side note: I really could not think of a good title for this. Ok,
I'm working on a web applications where - believe it or not- the users

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.