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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:18:05+00:00 2026-06-15T08:18:05+00:00

I have a text file, say, input.txt and I want to run a command

  • 0

I have a text file, say, input.txt and I want to run a command and write the output to another text file, say, output.txt. I need to read values from input.txt, each value is in a line, then I need to insert them in the command then write the result in output.txt file. I tried the following and it works fine with me:

for i in `cat input.txt`; do command -m $i -b 100; echo $i; >> output.txt; done

Now, I need to make some improvements over this but I have little experience in Linux so I need some help.

What I need to do is:
1) Before each command result, I want to insert the value of i separated by comma. For example:

i1,result1 
i2,result2
i3,result3

2) I need to change the second fixed value that I used in my command from a fixed value (100) to a value read from input.txt. So, the new input file which contains two values, say, newinput.txt is as the following:

i1,value1
i2,value2
i3,value3
  • 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-15T08:18:06+00:00Added an answer on June 15, 2026 at 8:18 am

    Try this, in bash:

    IFS=','
    while read i val; do
      echo -n "$i,"
      command $i $val
    done < input.txt > output.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file as input like this:let say it as xyz.txt TIME
Let's say I have a text file that is 100 lines long. I want
Let's say I have a text file of basic mathematical functions. I want to
Let's say I have a program to write text into a file (not really
Let's say I have an input text file of the following format: Section1 Heading
Lets say I have a modestly sized text file (~850kb, 10,000+ lines) And I
I have a source of strings (let us say, a text file) and many
If I have a a textfile say file.txt and it contains random words like:
I have this script in index.php file: <script type=text/javascript> $(document).ready(function(){ $('#ads').load('output.php').fadeIn('slow'); }); </script> And
I have a text file which is read in. It has delimeters which are

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.