2012-09-10 47 views
0

我想要搜索存储库文件以查看我的目录中是否有文件。为了做到这一点,我循环目录,希望包含我正在寻找的文件,并检查该文件是否在我的repository.txt中。如果它在那里,我更改布尔值,然后在比较存储库中的所有文件后,检查该布尔值的值。Bash变量作用域

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 

有没有一种方法可以让我坚持不断变化的布尔值,或者是有其他,这样做的更聪明的方式?请让我知道,如果你有任何问题。

回答