The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 03-17-2009
AlbertGM AlbertGM is offline
Registered User
  
 

Join Date: Mar 2009
Location: Barcelona - Catalonia
Posts: 28
Quote:
Originally Posted by puzzler View Post
[...]
I have two files,

folder 1 contains a list of around 20 files in binary (possibly treated as arrays?)

folder 2 contains several files and sub folders each entry also in binary

all i want to do is basically take each entry of folder 1 and see if there are any matching results in file 2
[...]
Are you talking about files or folders?? However you can compare files and/or folders using diff.
Another possibility could be list files in folder 1 and check if they exists in folder 2. Then, use diff to compare. Something like:

Code:
LIST=files.txt
ls folder1 > $LIST #list files from folder1
cat $LIST| while read line; do #for each filename
   INPUT=$(echo ${line})
   cd $folder2
   if [ -f $INPUT ]; then #check if file exists and its a regular file
      #files exists
      diff $folder1/$INPUT $folder2/$INPUT > dev/nul 2>&1 #compares both
      if [ "$?" == "0" ]; then #check for result.
         #files exists and they're identical
      fi
   fi
done

I'm not sure if you searching for something like this. If so, check it, because it can contain some error: I'm also a newbie

Albert.