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

  • Home
  • SEARCH
  • 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 8170113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:04:12+00:00 2026-06-06T21:04:12+00:00

Okay so basically I want to be able to use a text file with

  • 0

Okay so basically I want to be able to use a text file with this format:

www.website.com 443 123.456.789.098
www.website2.com 443 765.432.101.234
....

as a source of input in which the script will take the website address and hold it in a variable and the same thing with the port and Ip address. So it would look like this:

website=www.website.com
port=443
ip=123.456.789.098

So far, I have tried this:

for line in [ cat $file_name ]; do
    website=`echo $line | cut -d" " -f1`
    port=`echo $line | cut -d" " -f2`
    ip=`echo $line | cut -d" " -f1`

But when i echo out the the variables all i get is this:

[
[
[

I can’t seem to figure out how to go about solving this issue.

  • 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-06T21:04:14+00:00Added an answer on June 6, 2026 at 9:04 pm

    Use this pattern instead:

    while read line ; do
        ... loop body ...
    done < "$file_name"
    

    Explanation: for var in word-list will assign the words in the list to the variable in order. So for the first loop, $line will expand to [ (first word in the list). The next word would be cat and then the value of file_name.

    To read from a file, you need to use I/O redirection.

    while, on the other hand, will execute the command that you passed as argument (read line). read will read one line from stdin and put the value into the variable that you passed as argument.

    The odd done < $file_name sets the stdin for read. And to make you life even more simple, you can use read to split the input for you:

    while read website port id ; do
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so basically I want to be able to retrieve keyboard text. Like entering
Okay, basically, I have a large list of phone numbers in a text file
Okay guys, basically the problem I'm having is this. I've been assigned to write
Okay I wasn't really sure how to word this question, but basically what I
Okay this question is very simple: I have a facebook page, and a website.
Okay,I've been following this tutorial http://coenraets.org/blog/android-samples/androidtutorial/ Basically it gives me exactly what i need
Okay what I want to do is something like this. |--> Child 1 (Parent=Root
Okay so basically I am creating a Workflow BPMS in SharePoint and I want
Okay, so basically when I click the below buttons I want a new separate
Okay so i have a packed a proprietary binary format. That is basically a

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.