The UNIX and Linux Forums  

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sticky Folders mjdavies UNIX for Dummies Questions & Answers 1 10-16-2008 07:45 AM
compiled binary file gives "cannot execute binary file" scgupta SUN Solaris 0 07-13-2006 02:59 AM
Copying Folders without some folders... ;-) chimpu UNIX for Dummies Questions & Answers 5 04-26-2004 01:25 PM
Backing up Folders without some folders...;) chimpu Shell Programming and Scripting 1 04-26-2004 11:02 AM
downloading folders in ftp eloquent99 UNIX for Dummies Questions & Answers 6 04-23-2003 04:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-17-2009
puzzler puzzler is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 2
Exclamation 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 (permalink)  
Old 03-17-2009
va2206 va2206 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 7
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 (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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0