2 while read loops?

后端 未结 4 640
孤独总比滥情好
孤独总比滥情好 2020-12-20 00:49

So the object of the script I\'m making is to compare files from two while read lists that have file path names in them...

while read compareFile <&3;         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 01:29

    while read newfile <&3; do   
     if [[ ! $newfile =~ [^[:space:]] ]] ; then  #empty line exception
        continue
     fi   
     #
     while read oldfile <&3; do   
     if [[ ! $oldfile =~ [^[:space:]] ]] ; then  #empty line exception
        continue
     fi   
        echo Comparing "$newfile" with "$oldfile"
        #
        if diff "$newfile" "$oldfile" >/dev/null ; then
          echo The files compared are the same. No changes were made.
        else
            echo The files compared are different.
            #
        fi    
      done 3

提交回复
热议问题