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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:40:51+00:00 2026-05-12T23:40:51+00:00

How come FILE_FOUND is 0 at the end of this bugger : FILE_FOUND=0 touch

  • 0

How come FILE_FOUND is 0 at the end of this bugger :

FILE_FOUND=0

touch /tmp/$$.txt

ls -1 /tmp/$$.* 2>/dev/null | while read item; do
    FILE_FOUND=1
    echo "FILE_FOUND = $FILE_FOUND"
done

echo "FILE_FOUND = $FILE_FOUND"

rm -f /tmp/$$.txt 2>/dev/null

??!!

On Unix FILE_FOUND stays at 1 (as it should), but on Linux (RedHat, Cygwin, ..) it jumps back to 0!!

Is it a Linux shell feature, not a bug? 🙂

Please help.

  • 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-12T23:40:52+00:00Added an answer on May 12, 2026 at 11:40 pm

    common issue which is caused because you’re piping into the while, which is therefore run in a subshell, which can’t pass environment variables back to its parent. I’m guessing that “unix” is different in this regard as you’re running a different shell there (ksh?)

    piping to the while loop may not be required. could you use this idiom instead?

    for item in /tmp/$$.*; do
        ....
    done
    

    If you must use a subshell, then you’ll have to do something external to the processes like:

    touch /tmp/file_found
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an example XML file that would come from the Android Client. <test>
how come this isn't working: $url = http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20xpath%3D%22%2F%2Fmeta%22%20and%20url%3D%22http://www.cnn.com%22&format=xml&diagnostics=false; $xml = (simplexml_load_file($url)) I get multiple
This error come in log. from='kutbi1@360degree/Smack' to='akash@360degree/Smack' type='error' id='hK1L6-5'> <si xmlns='http://jabber.org/protocol/si' id='jsi_191216212994140179' mime-type='image/png' profile='http://jabber.org/protocol/si/profile/file-transfer'>
This problem seems to come up for a few people, but I haven't been
Sometimes you come by Zip files with file or directory with some unrecognized characters
I have downloaded several new plugins which come with a help file. None of
I know new rails apps come with an empty favicon.ico file. I want to
Come across what looks at first sight like an MT-issue, but I'm trying to
How come I can't access the hidden instance variable a in the line (int
I come from the Java world, so to me it's all object.foo() , but

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.