mardi 2 octobre 2018

loop through a directory and check if it exist in a nother directory

I have a folder with 20000 files in directory A and another folder with 15000 file in another directory B i can loop through a directory using :


DIR='/home/oracle/test/forms1/'

for FILE in "$DIR"*.mp
do
   filedate=$( ls -l --time-style=+"date %d-%m-%Y_%H-%M" *.fmx |awk  '{print $8 $7}')
    echo "file New Name $FILE$filedate "
#    echo "file New Name $FILE is copied "
done


i need to loop through all the files in directory A and check if they exist in directody B

i tried the following but it doesn't seem to work

testdir='/home/oracle/ideatest/test/'
livedir='/home/oracle/ideatest/live/'

   for FILET in "$testdir" #
       do
          testfile=$(ls $FILET)
          echo $testfile

   for FILEL in "$livedir"
       do
          livefile=$(ls $FILEL)

    if [ "$testfile" = "$livefile" ]
        then
                echo "$testfile"
                echo "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
        else
                echo "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn"
            fi

   done
   done


Aucun commentaire:

Enregistrer un commentaire