finding difference between 2 directory recursively


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting finding difference between 2 directory recursively
# 1  
Old 04-09-2008
finding difference between 2 directory recursively

Hi,
i'm trying to compare two directories in Unix.
I need a recursive search ie my shell script should also compare common files in those two directory and so on...
any clues.. ??
# 2  
Old 04-09-2008
Please elaborate as to what your ultimate goal is.

Here's one idea:

For each directory, do a "find ." and save the output to a file. In each file, strip out the first part of the path (which would be different between the two files). Cat the files together, piped to "sort | uniq -c" and save that output.

The result will be that if your output file shows a 1 before the line, then that file exists only in one of the two directories, and if a 2, then it exists in both.

ShawnMilo
# 3  
Old 04-09-2008
do a man for dircmp
Note: you might want to send the output to a file, and also pipe it to uniq to get rid of some of the blank lines.
Code:
dircmp -s /dir1 /dir2 

dircmp -s /dir1 dir2 | uniq > outfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy files recursively to one single directory

I need to copy a complete directory structure into a new location. But I want to have all files copied into one directory and leave out the directory structure. So all files must be placed in one directory. (4 Replies)
Discussion started by: ReneVL
4 Replies

2. Shell Programming and Scripting

How to recursively copy directory only for recent files?

I love the -newerct flag for the Cygwin find command on windows. Can I use "/usr/bin/find . -newerct '3 hours ago'" to conditionally copy a directory tree so that only the files in the directory tree that are younger than 3 hours are copied to my destination directory such that the directory... (4 Replies)
Discussion started by: siegfried
4 Replies

3. Shell Programming and Scripting

How to recursively search for a list of keywords in a given directory?

Hi all, how to recursively search for a list of keywords in a given directory?? for example: suppose i have kept all the keywords in a file called "procnamelist" (in separate line) and i have to search recursively in a directory called "target/dir" if i am not doing recursive search then... (4 Replies)
Discussion started by: neelmani
4 Replies

4. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46 Any ideas how can we do this? :wall: (1 Reply)
Discussion started by: jakerock
1 Replies

5. Shell Programming and Scripting

Need to find recursively all shell script in the /xyz directory

Pls. advise how to find or used grep recursively all shell script files. Some files doesnt have a .sh or .ksh extension name. find / -name "*" |xargs grep bin |grep sh ?? TIA (1 Reply)
Discussion started by: budz26
1 Replies

6. Solaris

grep recursively in a directory

Hi, how to grep recursively in a directory on Solaris OS. grep -r throws an error that -r is an invalid option. Please tell me if you have any solution. Regards, Jeevan. ps. I searched this forum for solution, but could not find anything useful. (4 Replies)
Discussion started by: jredx
4 Replies

7. UNIX for Dummies Questions & Answers

finding called functions recursively

I want to write a shell script which traverses a cpp file. Suppose there is function fncn_name6 .. which is called by fncn_name5 which in turn called by fncn_name4 and so on .. in a single cpp class. ie fncn_name1 { fncn_name2 { fncn_name3 } { fncn_name4 } } so fncn_name1 is... (2 Replies)
Discussion started by: ultimatix
2 Replies

8. Shell Programming and Scripting

delete files recursively in the specified directory

I have to write a shell script which can delete all the files and directories recursively inside the specified directory but should not delete the specified directory. Please some body help me in writing the script. (3 Replies)
Discussion started by: deepthi.s
3 Replies

9. Shell Programming and Scripting

delete files older than 5 minutes in directory (recursively)

sorry guys can some please give me a hint how to achieve this in a slick oneliner? delete files older than 5 minutes in specified directory (recursively) peace (3 Replies)
Discussion started by: scarfake
3 Replies

10. Shell Programming and Scripting

Recursively copy only specific files from a directory tree

Hi I am a shell-script newbie and am looking to synchronize certain files in two directory structures. Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over. I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)
Discussion started by: sharpsharkrocks
3 Replies
Login or Register to Ask a Question