Bash variable scope
I want to search a repository file to see if I have a file in my directory. To do this, I loop the directory hopefully containing the file I am looking for, and I check to see if that file is in my repository.txt. If it is in there, I change a boolean, and then check the value of that boolean after I compared all the files in the repository.
for file in * do inThere=false cut -d, -f1 $repo | while read line do echo "comparing "$line" == "$file" " if [ "$line" == "$file" ]; then inThere=true echo "I got tripped!!" #inThere is true echo "in there is $inThere" fi done echo "in there is $inThere" #inThere is false done
Is there a way I can persist the changing boolean value, or is there another, smarter way of doing this? Please let me know if you have any questions.
while read ... do ... done < <(cut ...)