Compare two folders and file content


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compare two folders and file content
# 22  
Hi,

You are close to the approach but what i need is like below to print the output in restive log files

Code:
f1.log - There is a difference in the f1 and f2, please find the below difference:
......
f2.log - No difference found
f3.log - No difference found
Additional.log - There is additional file in D2 with filename as f4

# 23  
Code:
diff -rs a b |  awk -F"[: \t]" '
        /^diff/ {
                N=split($3, A, "/");    N=A[N]".log"

                print "difference between " $3, $4 >> N
                getline ; getline

                while(/^[<>-]/) { print >> N ; if(getline != 1) break }

                close(N)
        }

        /^Only in/ {
                N=split($3, A, "/");    N=A[N]".log"
                print "There is additional file in "$3" with filename as "$NF >N
                close(N)
        }

        /identical$/ {
                N=split($2, A, "/");    N=A[N]".log"
                print A[N] " - no difference found" >> N
                close(N)
        }'

If you post any more demands or bumps showing no effort on your part, this thread will be closed. We are not a free scriptwriting service.
This User Gave Thanks to Corona688 For This Post:
# 24  
Quote:
Originally Posted by rohit_shinez
Hi,
Code:
f1.log - There is a difference in the f1 and f2, please find the below difference:
......
f2.log - No difference found
f3.log - No difference found
Additional.log - There is additional file in D2 with filename as f4

So, will the names of the log files follow a timeline? like the date/time of the test? or will they inherit the names of the added files?
Or are you going to be watching certain directories and creating logs for just those?
# 25  
Hi ongoto,

The log files doesn't follow time line and the logs will be created based on files present in respective directories
# 26  
Quote:
Originally Posted by rohit_shinez
Hi ongoto,

The log files doesn't follow time line and the logs will be created based on files present in respective directories
If you mean a logfile for every file on your system....
hmmm
You need something like tripwire.
Can't help you there.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #878
Difficulty: Medium
Memory allocation is less critical in a real-time operating system (RTOS) than in other operating systems.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to compare files in 2 folders and delete the large file

Hello, my first thread here. I've been searching and fiddling around for about a week and I cannot find a solution.:confused: I have been converting all of my home videos to HEVC and sometimes the files end up smaller and sometimes they don't. I am currently comparing all the video files... (5 Replies)
Discussion started by: Josh52180
5 Replies

2. Shell Programming and Scripting

Compare & print content of file which is not matching

Hi All I want to compare 2 files using awk and get output of content which is not matching I have 2 files a.txt 123 456 780 143 b.txt A|B|C|167|D|E C|K|D|123|D|E A|B|D|789|G|F C|D|G|143|A|B Not matching line from b.txt O/P A|B|C|167|D|E A|B|D|789|G|F (3 Replies)
Discussion started by: aaysa123
3 Replies

3. Shell Programming and Scripting

Move multiple files 4rm Source to different target folders based on a series num in the file content

Dear Experts my scenario is as follows... I have one source folder "Source" and 2 target folders "Target_123456" & "Target_789101". I have 2 series of files. 123456 series and 789101 series. Each series has got 3 types of fiels "Debit", "Refund", "Claims". All files are getting... (17 Replies)
Discussion started by: phani333
17 Replies

4. Shell Programming and Scripting

Ksh: how compare content of a file with an other array

Hi, I created a skript in ksh which generate a file with semicolon as separator, this is an example of the file a created: example content file: hello;AAAA;2014-08-17 hello;BBBB;2014-08-17 hello;CCCC;2014-08-17 I would need to compare the content in of the second column of this file... (3 Replies)
Discussion started by: jmartin
3 Replies

5. Shell Programming and Scripting

Bash selective copy folders and content to another location

I'm looking for a bash scrypt to copy some folders and some of the content to another location. I'm a teacher and very noobish with programming language anyway what I'm looking for , I have this director structure Main director "Students" with subfolders "john";"daisy";"work" etc .. and some of... (2 Replies)
Discussion started by: brickleul
2 Replies

6. Shell Programming and Scripting

split file content into specific folders

Hi I have a large text file and I want to split its content into multiple flies. this large file contains several blocks of codes separated by a comment line for each block. this comment line represents a directory path So, when separate these blocks each into a separate file, This output... (7 Replies)
Discussion started by: turki_00
7 Replies

7. Shell Programming and Scripting

Compare 2 folders...

Hello, I try to compare 2 folders, i explain, i have file in this 2 folder and i want to print out the difference in this folders... ex: folder1: file1 file2 file3 folder2: file1 file2 print file3 I do a ls of the 2 folders and i use the command diff (diff $var1 $var2) without... (8 Replies)
Discussion started by: protocomm
8 Replies

8. UNIX for Dummies Questions & Answers

To compare selective file in different folders

Hello, I am using dircmp -d <folde1> <Folder2> to compare the files from two different foldes, but this command compares for all the files. Is there any option to select only some files for comparision. For example in Folder1: file1.txt file2.txt file3.txt Folder2 file1.txt file2.txt... (0 Replies)
Discussion started by: gmahesh2k
0 Replies

9. Shell Programming and Scripting

To Compare content of one file with other file

Hi All, I need to compare the content of one file with the other.The first file holds the records: aaa ,123 bbb,321 ccc,890 Second file willl holds the record aaa,bbb,ccc My problem is i need to take the first column of file one and compare with the first row of second file.If it... (1 Reply)
Discussion started by: ithirak17
1 Replies

10. Shell Programming and Scripting

Remote compare of folders

Hi, Is there a way (either commands/tools/scripts/logic) to compare two given folders on different unix boxes. I want to compare folder a in Unix box 'A' with folder 'b' in Unix box 'B'. I can run the script in Unix box 'A'. I am looking. for following results: files/sub folders only in a... (1 Reply)
Discussion started by: sunilav
1 Replies

Featured Tech Videos