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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:15:17+00:00 2026-06-01T17:15:17+00:00

This piece of code is working absolutely fine when I am executing it individually

  • 0

This piece of code is working absolutely fine when I am executing it individually

for i in {1..13}
do
echo "<td class = 'loop'>

</td>"
done

But when I am putting this inside a bash script I am getting only one iteration,instead of 13 iteration.

The whole script looks something like

while read variable
do
//something
done<a.txt

for i in {1..13}
do
echo "<td class = 'loop'>

</td>"
done

Can any one help me out.

EDIT

     #/!/bin/bash
while read  host 
do  



    y=$(($y+1)) 

    count=$(ping -c $COUNT $host | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
    if [ $count -eq 0 ]; then
                if [ -n "$host" ]; then
                    echo "<td class ='statuscellred'>" >>table1.html
                    echo  "$host" | cut -d'.' -f1 >> table1.html
                    echo "</td>" >> table1.html
                    if [ $(($y % 13)) -eq 0 ] ; then
                        echo "</tr>">>table1.html
                        echo "<tr>">>table1.html
                    fi  
                else
                    echo "<td class ='statuscellblanck'>" >>table1.html
                    echo "$host" >> table1.html
                    echo "</td>" >> table1.html
                    if [ $(($y % 13)) -eq 0 ] ; then
                        echo "</tr>">>table1.html
                        echo "<tr>">>table1.html
                    fi
                fi

    else
        if [ -n "$host" ]; then
                    echo "<td class ='statuscellgreen'>" >>table1.html
                    echo  "$host" | cut -d'.' -f1 >> table1.html
                    echo "</td>" >> table1.html
                    if [ $(($y % 13)) -eq 0 ] ; then
                        echo "</tr>">>table1.html
                        echo "<tr>">>table1.html
                    fi  
                else
                    echo "<td class ='statuscellblanck'>" >>table1.html
                    echo "$host" >> table1.html
                    echo "</td>" >> table1.html
                    if [ $(($y % 13)) -eq 0 ] ; then
                        echo "</tr>">>table1.html
                        echo "<tr>">>table1.html
                    fi
                fi
    fi




done < server1.txt

for i in {1..13}
do
echo "<td class = 'loop'>

</td>">>table1.html
done

and here is server1.txt

     1.com
2.com
3.com
4.com
5.com

7.com
8.com


9.com

11.com

13.com

15.com
  • 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-01T17:15:18+00:00Added an answer on June 1, 2026 at 5:15 pm

    Based on the posted code, the shebang line is not formed correctly. It should be:

    #!/bin/bash
    

    with no leading spaces (posted version has an extra / in it). As it stands, if you execute that in a shell it’ll be interpreted by the current shell, and the first line is merely a comment.

    [taken from my comment as it appears to have resolved the OP’s problem]

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

Sidebar

Related Questions

this piece of code worked fine on my machine, but it doesn't on my
This piece of code is working fine with normal php: <?php function barber($type) {
I'm not entirely sure why this isn't working. But this piece of code does
I have this piece of code for MFMailComposer working fine in the simulator and
can anyone help me with this code. Everything is working fine except this piece
I have this piece of code that is working but is kind of cumbersome.
Why this piece of code is working on my fsi, but can't build the
I have this piece of code that is working fine in python 2.7. dist
I have this piece of code, but can't seem to get it working. success:
Why is this piece of code not working on Chrome 4.0 but works on

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.