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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:42:35+00:00 2026-06-11T19:42:35+00:00

How can you read into variables using IFS and a variable? I am trying

  • 0

How can you “read” into variables using IFS and a variable?

I am trying to loop over some data paired by a pipe to be split and worked on. The error I am getting is read: 'site|database': not a valid identifier

SITES="abc|abc xyz|asdf"
for site in $SITES;
do
  IFS="|" read domain database <<< echo $site; # es no bueno mi amigo
  echo "Site: $domain \t\t\t Database: $database";
done;

Am I just doing this the hard way? I am not a native Basher. 😉

  • 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-11T19:42:36+00:00Added an answer on June 11, 2026 at 7:42 pm

    The problem with your script is that you are not passing the Here String to read correctly. It should be done like this:

    IFS=$"|" read domain database <<< "$site" # es no bueno mi amigo
    

    Remember to quote the variable as well.

    Your script will then work.

    Here is the fixed script:

    SITES="abc|abc xyz|asdf"
    for site in $SITES
    do
      IFS="|" read domain database <<< "$site" # es no bueno mi amigo
      echo -e "Site: $domain \t\t\t Database: $database"
    done
    

    It prints:

    Site: abc                        Database: abc
    Site: xyz                        Database: asdf
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to insert non-latin data into sqlite database using bind variables using System.Data.SQLite.
i want simultaneously read and write data into file. Can i use StreamReader and
How can I read XML in the attribute format into a ExtJS Store, where
In php how can I read a text file and get each line into
I can read unmanaged memory in C# using UnmanagedMemoryStream, but how can I do
I have read the docs over and over trying to wrap my head around
You can read this question where I ask about the best architecture for a
I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);
I can read XLS file with this code : string path =@c:\r\1.xlsx; OleDbConnection MyConnection
How I can Read the RGB-Pixel by Pixel values from CGImagea also after how

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.