2

したがって、私が作成しているスクリプトの目的は、ファイル パス名を含む 2 つの読み取りリストからファイルを比較することです...

while read compareFile <&3; do     
 if [[ ! $server =~ [^[:space:]] ]] ; then  #empty line exception
  continue
 fi   
    echo "Comparing file - $compareFile"
 if diff "$compareFile" _(other file from loop?_) >/dev/null ; then
    echo Same
 else
     echo Different
 fi   
 done 3</infanass/dev/admin/filestoCompare.txt

2 つの while read ループを使用して、同時に 2 つの異なるリストからファイルを比較できるようにする必要があります...これは可能ですか?

4

4 に答える 4

0
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</home/u0146121/test/oldfiles.txt
 done 3</home/u0146121/test/newfiles.txt
于 2013-07-11T12:58:52.247 に答える