I want to record the difference in the content of files in different directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I want to record the difference in the content of files in different directory
# 1  
Old 02-08-2007
I want to record the difference in the content of files in different directory

Hi All

I am very new to the Unix shell scripting ,, could you pleae help me to generate the output file having the filename and path which files having the difference in the contents in the two directory. all files in both directory have the same name and format.

input directory /edc/input1/ it also can have sub directory
/edc/input2/ it also can have sub directory
output file diffout having path and name fo file.

please let me know if this requremnt are not clear
please provide me some sample script.

thanks

Singh
# 2  
Old 02-08-2007
If I understand correctly, try this

cd /edc/input1 ; find . -type f | sort > /tmp/input1.lst
cd /edc/input2 ; find . -type f | sort > /tmp/input2.lst
diff /tmp/input1.lst /tmp/input2.lst


From the output, lines that begin with a less-than sign '<' exist only in /edc/input1 and those beginning with a greater-than sign '>' exist only in /etc/input2. To see which files exist in BOTH directories, use the join(1) command

join /tmp/input1.lst /tmp/input2.lst
# 3  
Old 02-13-2007
I want to record the difference in the content of files in different directorys

Hi hegemaro

diff /tmp/input1.lst /tmp/input2.lst

is not giving any output. beacuse it is having the same file name in both of the list. i want to print the filename along wiht the path, which having diffrent contents, could u please giv me any idea how can we do this ..

Singhal
# 4  
Old 02-13-2007
Code:
ls /dir1 | while read x
do
str=$(diff /dir1/$x /dir2/$x )
[[ -n "$str" ]] && echo $x
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Comparing two files and list the difference with common first line content of both files

I have two file as given below which shows the ACL permissions of each file. I need to compare the source file with target file and list down the difference as specified below in required output. Can someone help me on this ? Source File ************* # file: /local/test_1 # owner: own #... (4 Replies)
Discussion started by: sarathy_a35
4 Replies

2. Shell Programming and Scripting

Total record count of all the file present in a directory

Hi All , We need one help on the below requirement.We have multiple pipe delimited .txt file(around 100 .txt files) present on one directory.We need the total record count of all the files present in that directory without header.File format as below : ... (8 Replies)
Discussion started by: STCET22
8 Replies

3. Shell Programming and Scripting

Directory containing files,Print names of the files in the directory that are exactly same content.

Given a directory containing say a few thousand files, please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents. func(a_directory_name) output -> {“matches”: , ... ]} e.g. func(“/home/my/files”) where the directory... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies

4. Shell Programming and Scripting

Find difference in content between two particular lines in two files

I have two files named Before.txt and After.txt: Now i want to find the difference in content between <Marker 1> and <Marker 2> in the two files. ---------- Post updated at 05:00 PM ---------- Previous update was at 04:50 PM ---------- Any help will be highly appreciated..:) (3 Replies)
Discussion started by: proactiveaditya
3 Replies

5. Shell Programming and Scripting

Help with keep the record with share content

Input file: 1234 USA date 3421 USA date 3421 USA content 1234 USA1 date 34 USA1 content 1234 USA2 Sun 34 USA2 Sun 43 USA2 Sun 345 USA2 date 435 USA2 date1 Output file: 1234 USA date 3421 USA date 1234 USA1 date 1234 USA2 Sun 34 USA2 Sun 43 USA2 Sun (0 Replies)
Discussion started by: perl_beginner
0 Replies

6. Shell Programming and Scripting

split content and write to new record

Hi, Help required to split record value and write to new row. Input a~b~c~value in ('3','4','5')~test output a~b~c~3~test a~b~c~4~test a~b~c~5~test input a~b~c~value in ('3','4')~test output a~b~c~3~test a~b~c~4~test (8 Replies)
Discussion started by: Jairaj
8 Replies

7. Shell Programming and Scripting

apply record separator to multiple files within a directory using awk

Hi, I have a bunch of records within a directory where each one has this form: (example file1) 1 2 50 90 80 90 43512 98 0909 79869 -9 7878 33222 8787 9090 89898 7878 8989 7878 6767 89 89 78676 9898 000 7878 5656 5454 5454 and i want for all of these files to be... (3 Replies)
Discussion started by: amarn
3 Replies

8. Shell Programming and Scripting

How to list the content of a directory

Hi I want to write a script that reads a directory name, checks if the directory exists and lists the content of that directory. That's what I have at the moment. function listDirectory { echo "Give in a directory name" read name #Here I want to check if the... (4 Replies)
Discussion started by: hss
4 Replies

9. UNIX for Dummies Questions & Answers

Move content from directory to another

I have in root directory a folder A and a Folder B. I want to copy or move all content (many files) from A to B. How do I do that UNIX style? Thanks! (6 Replies)
Discussion started by: Matsakii
6 Replies

10. Shell Programming and Scripting

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 Replies)
Discussion started by: yayati
2 Replies
Login or Register to Ask a Question