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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:39:50+00:00 2026-05-25T19:39:50+00:00

Can anyone explain the control flow of the following bash script? while IFS= read

  • 0

Can anyone explain the control flow of the following bash script?

while IFS= read -r file
do 
rm -rf "$file"
done < todelete.txt

From what I understand, this would happen:

IFS would be assigned nothing.
The rm -rf command would do nothing because its argument, the variable $file, is blank/empty/nothing.
The two previous steps would then repeat indefinitely.

Clearly this is not the case, because the script works as expected; it deletes all files listed in todelete.txt.

I believe the explanation lies in “done < todelete.txt” but I don’t understand what’s happening there.

  • 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-25T19:39:51+00:00Added an answer on May 25, 2026 at 7:39 pm

    The redirect after done affects read‘s input stream. So read will work on the contents of todelete.txt rather than stdin.

    You should read the Internal Commands section of the Bash manual for more info. (Browse directly to example 15-7.)

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

Sidebar

Related Questions

Can anyone explain exactly how the Strategy Pattern relates to Inversion of Control?
Can anyone explain why you can’t use inline code blocks within server control declarations
Does anyone know where I can find a good video to explain version control
Can anyone explain why following code won't compile? At least on g++ 4.2.4. And
Can anyone explain how to control the XML generated ? I have a simple
Can anyone explain reasons why the name property of a Repeater control's child controls
I'm having a problem with WebBrowser control in WP7. Can anyone explain to me
Can anyone explain what this mod_rewrite rule is doing? I'm trying to comment the
Can anyone explain what advantages there are to using a tool like MSBuild (or
Can anyone explain in simple words what First and Second Level caching in Hibernate/NHibernate

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.