perform diff between 2 directories


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers perform diff between 2 directories
# 1  
Old 05-02-2006
perform diff between 2 directories

Hello all
i wander what is the best way to make diff between 2 directories and perform diff of 2 kinds
the first is the names of the files on each directory , and the second diff is between the content of
each file and the corresponding file and the second dir.

Thanks for the help
# 2  
Old 05-02-2006
here ...

Ok, while there are MANY ways to do so, let me suggest you some simplest:
First “diff” supposed to differentiate between files, so you may wish dump the output of the directories in the files first:

Like “ls -1 > file1” in one directory and “ls -1 > file2” in another directory. Option “-1” instructs ls to format output one name per line as it will make it more convenient for our use. So then you can use “diff file1 file2”.
As you want to compare the content of the files in the directories, the simplest is to dump the files from the first directory into one file and files from another directory into another.
To do so you can use command “xargs” as it creates list of parameters: “cat file1 | xargs cat > filedir1” . You can use < instead of the first “cat” in the line. You then do the same with a second file you have created and then you can run diff for these two new files and account for a differences in file content. I hope it is what you have been asking for.
Get “UNIX in 24 hours” or “UNIX Essentials and UNIX Core” DVD if you have questions of this sort.

Hope it helps.
# 3  
Old 05-02-2006
If you prefer an interactive GUI tool to examine diffs, you can always try tools such as meld, kdiff3 and kompare.

For text-based diffs, for filename diffs you can always do a

ls -R dir1 >TXT1
ls -R dir2 >TXT2
diff -u TXT1 TXT2

For content diff you can do

diff -Naur dir1 dir2
# 4  
Old 05-04-2006
diff -Naur dir1 dir2
seams not to work in sparc SUNW,Sun-Fire-V490 ...
# 5  
Old 05-04-2006
Probably. What about just

diff -r dir1 dir2

?
This User Gave Thanks to cbkihong For This Post:
# 6  
Old 08-25-2006
wat if you only want to list the files in dir1 or dir2 which are similar in name, but differ in content rather than the actual diff output?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing two directories with diff

Hi all, I have 2 directories on two different servers. I am trying to find out what is missing from directory X and what is missing from directory Y. they should both have the same exact files in them. I understand some files may be missing from both directories on each server. I am not sure... (8 Replies)
Discussion started by: jeffs42885
8 Replies

2. Shell Programming and Scripting

Help with create multiple directories under diff file systems

Hi, Need help ...I want to create multiple directories in different /file systems using for loop..eg.../ORCL_data01/oradata/orcl/ctl. ../ORCL_data01/oradata/orcl/data. ../ORCL_data01/oradata/orcl/redo. Script :- ========= for dir in `ls -d... (8 Replies)
Discussion started by: Linux6.5
8 Replies

3. Shell Programming and Scripting

Comparision of two directories of diff servers

Hi All, I have transferred some directory structures from server1 to server2 by creating a tar files. Now i need to cross check whether I transferred entire structures or not. Is there any command to check this on each individual server. Thanks (2 Replies)
Discussion started by: nag_sathi
2 Replies

4. Shell Programming and Scripting

[Solved] Perform an operation to all directories

Sorry, about this thread - I solved my own problem! Thanks for taking a look. edit by bakunin: no problem, but it would have been a nice touch to actually tell us what the solution was. This would have been slightlich more educating than just knowing that you found it. I changed your title to... (0 Replies)
Discussion started by: Blue Solo
0 Replies

5. UNIX for Dummies Questions & Answers

Change chmod on files in diff directories

I am looking for a small script to crawl through several directories and change a couple of files in each directory to read write status. Anyone have any ideas ? (5 Replies)
Discussion started by: zapper222
5 Replies

6. Shell Programming and Scripting

How to access files from different directories and to perform search action in those files?

Hi, I want to access files from different directories (for example: /home/dir1/file1 , /home/dir2/file2 ...) Like this i have to access these files(file1, file2...). (3 Replies)
Discussion started by: bangarukannan
3 Replies

7. UNIX and Linux Applications

CVS recursive diff -- how to exclude specific directories?

I think I've seen out there that there is a command to ignore specific files within a directory when doing a (-R) recursive diff. I've never used this so I was wondering if there was anyone who could provide an example how I would run this. My thoughts are something like: cvs diff -i <fileName1>... (2 Replies)
Discussion started by: airon23bball
2 Replies

8. UNIX for Dummies Questions & Answers

Using diff on files in different directories

Hi, I want to be able to compare two different files in two different directories. I have a development server set up on one domain and a live server set up on another.....I need to be able to compare files on these two servers. Any ideas? (2 Replies)
Discussion started by: elduderino
2 Replies

9. UNIX for Dummies Questions & Answers

Compare/Diff between directories and subdirectories?

Hi, Does anybody know the cmd to compare two areas and print out the different files w/ path? I tried cmp and diff and dircmp but with no luck. Should I grep and print? For example: /aa/images/jan ..../images/feb /bb/images/jan ..../images/feb i want to print the compare,... (5 Replies)
Discussion started by: andylee80
5 Replies

10. Shell Programming and Scripting

perl package directories - what if the script is diff DIR to the one contain *.pm?

Hi there, say the package is in the ~/ and it's ~/packageFoo.pm I can use usePackage.pl in ~/ (~/usePackage.pl). Now, if I move it to ~/subDIR/usePackage.pl, the script won't work because it's not in the same DIR with packageFoo.pm How can i fix it? Thanks Gusla (1 Reply)
Discussion started by: gusla
1 Replies
Login or Register to Ask a Question