Comparing Two Binary Folders


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparing Two Binary Folders
# 1  
Old 03-17-2009
Error Comparing Two Binary Folders

I am a beginner to all of this but undertand the basic principles. I am currently working on a large task and struggling with a the final part.

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, if there is any matches they should then be moved to a text folder 3

any solutions?
# 2  
Old 03-17-2009
Hi,

Comparing two files you can use below one..

this might help you..

awk 'FNR==NR {a[$0]++; next} a[$0]' file1 file2


Thanks
Va2206
# 3  
Old 03-17-2009
Quote:
Originally Posted by puzzler
[...]
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 Smilie

Albert.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

When comparing binary files, show human readable result?

Hello. I am comparing two binary file. The first file is the source file. The second file is a modified version of the first one. Modification concern uuid value. Example first file have multiple occurrences of 69a3604b-ac2b-43b7-af84-0a4a67fc6962 second file have the same occurence... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Comparing folders - autocopy script

Hey Guys, first of all: I'm new to unix and im not very experienced. I've bought a rapsberry pi and i want it to be the backup-machine for my SD-Cards while im travelling (attached ssd, card reader, a small touch-tft) I managed to modify it a litte bit (its sending information bubbles to the... (3 Replies)
Discussion started by: Eomer
3 Replies

3. UNIX for Dummies Questions & Answers

Archive folders and sub folders

Hi Can i archive folder and folders in with the tar command My files are located in subfolders Eg: Folder1/Folder1_1/*.pdf Folder1/Folder1_2/*.pdf Folder1/Folder1_3/*.pdf so i would like to tar all the files in Folder1_1 and Folder1_2 only not Folder1_3 that should be done next... (2 Replies)
Discussion started by: cnrj
2 Replies

4. Shell Programming and Scripting

Copy between two different folders containing same sub-folders

I have a folder like this ls input1 dir1 dir2 dir3 file1 file2 file3 dir1, dir2 and dir3 are sub-folders inside the folder input1 ls input2 dir1 dir2 dir3 file1 file2 file3 My dir1 in input1 folder has files f1, f2, f3 and f4. My dir1 in input2 folder has file f4 and f5. ... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

5. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

6. Shell Programming and Scripting

Comparing two folders

Hi, Can you tell me how to compare two directories and write the differing files to some other folder? (5 Replies)
Discussion started by: arijitsaha
5 Replies

7. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

8. Shell Programming and Scripting

Making 99 folders 99 folders deep

I am trying to make a unix shell script that will make 99 folders 99 deep (counting the first level folders). So far i have made it make the first 99 folders and 99 more in all of the folders. The only problem is the only way i have found is copying and pasting part of the script over and over and... (18 Replies)
Discussion started by: YukonAppleGeek
18 Replies

9. UNIX for Dummies Questions & Answers

Copying Folders without some folders... ;-)

I am in a fix....... I have to write a backup script to backup say Folder A. Folder A contains n folders 1,2 ,3 .....n. my script should copy A without folder 2 & 3. Is there anyway I can do it without writing individual copy commands???? Please help.... (5 Replies)
Discussion started by: chimpu
5 Replies

10. Shell Programming and Scripting

Backing up Folders without some folders...;)

I am in a fix....... I have to write a backup script to backup say Folder A. Folder A contains n folders 1,2 ,3 .....n. my script should copy A without folder 2 & 3. Is there anyway I can do it without writing individual copy commands???? Please help.... (1 Reply)
Discussion started by: chimpu
1 Replies
Login or Register to Ask a Question