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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:24:55+00:00 2026-05-30T17:24:55+00:00

Let me introduce my loop to you all: NUM_LINE=0 while read line; do let

  • 0

Let me introduce my loop to you all:

NUM_LINE=0
while read line; do
  let NUM_LINE+=1
  if [ $NUM_LINE -lt 41 ]; then
    echo -e "\t$BLANC|$ORIGINAL $line $BLANC|"
  else 
    echo -e "\n\t$BLANC## "$GRIS"Llista de Nodes sel·leccionats    $BLANC############$ORIGINAL\n"
    read AUX
    NUM_LINE=0  
  fi
done <$NODES

So that:


$BLANC is \033[1;37m
$GRIS same
$ORIGINAL as well
$NODES is the absolute path of a file containg a lot of lines like:
| 23127 myserver 98.194.263.29 |

The Problem:


The echo inside the else statement it’s properly triggered.
But it doesn’t happen the same with the read statement

Any suggestion?

  • 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-30T17:24:56+00:00Added an answer on May 30, 2026 at 5:24 pm

    The reason that the loop doesn’t function properly is because read is reading from stdin in both cases. You need to open an alternate file descriptor to your file and read from the file descriptor.

    exec 3<$NODES
    NUM_LINE=0
    while read -u 3 -r line; do
      (( NUM_LINE++ ))
      if (( NUM_LINE < 41 )); then
        echo -e "\t$BLANC|$ORIGINAL $line $BLANC|"
      else 
        echo -e "\n\t$BLANC## "$GRIS"Llista de Nodes sel·leccionats    $BLANC############$ORIGINAL\n"
        read AUX
        NUM_LINE=0  
      fi
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have an array of zeros: a = numpy.zeros(1000) I then introduce
I read this post about contravariance: Let's now introduce another wildcard: ? super .
let me introduce my story first. To develop a multiplayer network game in facebook,
Firstly, let me introduce general architecture of a project. It is hierarchical. We develop
First let me introduce the application scene: I have a service application which is
Let me introduce another of IE's tricks! Today, to my surprise I have the
First let me introduce implementation without Dependency Injection (which will break Dependency Inversion Principle):
Let me quickly introduce myself: over 30 years of programming in general, over 12
let me introduce. I'm an enthusiast programmer (not professional) with c, c++, java experience
There's something I recurently struggle with while working on C++ code. Let's say I've

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.