The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


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


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
du from list with du of list total Movomito Shell Programming and Scripting 3 05-04-2008 06:33 PM
Comparing 2 list and deleting deuplicate entries eltinator Shell Programming and Scripting 10 08-15-2007 10:35 AM
how to generate a random list from a given list mskcc Shell Programming and Scripting 3 05-30-2006 12:30 AM
how to list dir only stephettt UNIX for Dummies Questions & Answers 2 02-22-2004 07:34 AM
Comparing data list... giannicello UNIX for Dummies Questions & Answers 4 03-06-2003 09:08 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-22-2004
Registered User
 

Join Date: Jun 2004
Location: KL
Posts: 7
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Comparing a distinct value in 1 list with another list

Hi all,

I need to compare the contents of 2 directories where the file contents are similar and take out the filenames whose contents does not exist within the 2 directories.

Directory1

1
2
3
4

Directory2

54
55
56
57

Does anyone has a script which can do this?
At the end of the command, all the files that does not exist when comparing the 2 directories should be cp -p to another new directory.

Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-22-2004
joerg's Avatar
Registered User
 

Join Date: Jan 2002
Location: Germany
Posts: 148
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Hi!
you can use sdiff with the option -s to print only not identical lines.

ls -la /first_dir > 1.dir
ls -la /seconed_dir >2.dir
sdiff -s 1.dir 2.dir

I hope this help.
regards joerg
Reply With Quote
  #3 (permalink)  
Old 06-22-2004
Registered User
 

Join Date: Jun 2004
Location: KL
Posts: 7
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Hi Joerg,

Thanks for your advice, but the filenames are totally different, however the content is the same, in this case, how would i go about doing it?

There are 800+ files in one directory and 500+ in one directory, i know for sure that about 200+ do not share the same contents and i want to move them to another directory.

Regards,
Alvin
Reply With Quote
  #4 (permalink)  
Old 06-22-2004
joerg's Avatar
Registered User
 

Join Date: Jan 2002
Location: Germany
Posts: 148
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Is the timestamp of the file in side the first directory the same as in the second directory.
Please give us a output of the ls -la command for both directorys.
Which kind of contense it is?
regards joerg
Reply With Quote
  #5 (permalink)  
Old 06-22-2004
Registered User
 

Join Date: Jun 2004
Location: KL
Posts: 7
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Hi Joerg,

No the only thing that is the same is the xml file contents, i need to compare the file contents in one directory with the other directory. Do you know of a script which can do that?

Regards,
Alvin

s the timestamp of the file in side the first directory the same as in the second directory.
Please give us a output of the ls -la command for both directorys.
Which kind of contense it is?
regards joerg
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB 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 -7. The time now is 04:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102