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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:10:28+00:00 2026-06-10T18:10:28+00:00

I am trying to write a simple bash script that will use a list

  • 0

I am trying to write a simple bash script that will use a list from a text document and curl each URL that is on the list in order to see what the contents of each URL is. It allows me to cURL 2 sites and creates the text documents for the rest however it only downloads the first 2. I have already manage to write the script that pulls there IP’s and places them in a seperate file using the grep command. At first i tried

#!/bin/bash
for var in `cat host.txt`; do
curl -s $var >> /tmp/ping/html/$var.html
done

I have tried with and without the silent switch. I then tried the following:

#!/bin/bash  
for var in `head -2 host.txt`; do  
curl $var >> /tmp/ping/html/$var.html  
wait  
done  
for var in `head -4 host.txt | tail -2`; do  
curl $var >> /tmp/ping/html/$var.html  
done  

This would try and do them all at the same time again stopping after 2

#!/bin/bash  
for var in `head -2 host.txt`; do  
curl $var >> /tmp/ping/html/$var.html   
done 
wait 
for var in `head -4 host.txt | tail -2`; do  
curl $var >> /tmp/ping/html/$var.html  
done  

This would do the same, I am new to bash scripting and only know some of the basics, any help would be appreciated

  • 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-10T18:10:30+00:00Added an answer on June 10, 2026 at 6:10 pm

    Start with the simple: verify that you are in fact iterating over the entire list:

    # This is the recommended way to iterate over the file. See
    # http://mywiki.wooledge.org/BashFAQ/001
    while read -r var; do
        echo "$var"
    done < hosts.txt
    

    Then add in the call to curl, checking its exit status

    while read -r var; do
        echo "$var"
        curl "$var" >> /tmp/ping/html/$var.html || echo "curl failed: $?"
    done < hosts.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple script that will list the contents found in
I am trying to write a simple bash script that will search for files
I am trying to write a simple bash script that will copy the entire
I'am trying to write simple script that will get files name from one folder
I am trying to write a simple Java function that will take a list
I'm trying to write (what I thought would be) a simple bash script that
I'm trying to write a bash script that will download all of the youtube
I'm trying to write a simple bash script that accepts all arguments and interprets
I'm trying write a simple perl script that reads some fields from a password
I am trying to write a simple bash script that is listening on 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.