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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:05:49+00:00 2026-05-23T15:05:49+00:00

all! I need to read arguments from a file ‘data’ that consists of strings

  • 0

all!

I need to read arguments from a file ‘data’ that consists of strings like:

-a -camb="1 0.5 1",diff="1 0 0" -q=5
-a -camb="0 1 0" -p -q -f=10
...

Next, that arguments must be passed to a program ./test within a script:

#!/bin/bash

while read line
do
    ./test "$line"
done < "./data"

the problem is that “$line” is passed as argv[1] to ./test, and not as a sequence of argv[1], argv[2], argv[3]

How can I split the string line to several arguments? I.e. the ./test must takes argv[1], argv[2], and so?

Note, that -camb=”1 0.5 1″,diff=”1 0 0″ must be as whole argument, argv[2]!

  • 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-23T15:05:50+00:00Added an answer on May 23, 2026 at 3:05 pm

    You can use eval for this:

    #!/bin/bash
    
    while read line
    do
        eval "./test $line"
    done < "./data"
    

    There’s a big warning here, however: eval may do more interpretation of the file contents than you want. For example, if it contains any I/O redirects (e.g. >somefile), they will be applied. Similarly, $variable will be substituted, ; somecommand will be executed as a separate command, etc. Basically, if the contents of the data file aren’t clean enough, you can get some unexpected and potentially dangerous results.

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

Sidebar

Related Questions

I need to read a PNG file and interpret all the information stored in
I have a problem. I need to trace all read/write operations to the registry
I have multiple threads (C# application running on IIS) running that all need to
So all I need is a simple function that sets it up (eating incoming
I've got a reasonably simple query (this time) that I need ALL the results
I need to embed the bibliography information from the .bbl file in the .tex
Suppose you are working with some data, which comes from a JSON file. You
I am supposed to write a program that should read from input numbers in
I have multiple threads who all need to write to the same Dictionary. I
All I need is a way to make a property of one class only

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.