Diff Command to return the number of lines inserted,deleted and changed.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Diff Command to return the number of lines inserted,deleted and changed.
Prev   Next
# 1  
Old 09-21-2009
Java Diff Command to return the number of lines inserted,deleted and changed.

Hello,
I have to compare two files file1 and file2, retrieve the number of lines modified (added, deleted or modified) in file2. Output must be like:

File2:
Added Deleted Changed Total
------ ------- -------- -----
2 1 1 4


Somebody please help me, Thanks in advance!!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk command to return only field with a number in it

What is an awk command to print only fields with a number in it?? Input file....... S,S,S,S,S,S,S,S,S 001S,S,S,S,S,S,S,S,S 00219S,23S,24S,43S,47S,S,S,S,S 00319S,10S,23S,41S,43S,47S,S,S,S 00423S,41S,43S,46S,47S,S,S,S,S 00510S,23S,24S,43S,46S,S,S,S,S 00610S,23S,43S,46S,47S,S,S,S,S... (2 Replies)
Discussion started by: garethsays
2 Replies

2. Shell Programming and Scripting

Changed Field Number

HI, I have two files and contains many Fields or columns with | (pipe) delimitor, wanted to compare both the files and get only unmatched perticular fields number. ex: first.txt 1 | 2 | 3 111 |abc| 230 hbc | bb2 | cs second.txt 1 | 2 | 3 111 |abc |230 abn | bb2 | fp Here the... (7 Replies)
Discussion started by: prawinmca
7 Replies

3. Shell Programming and Scripting

Get the changed field number

HI, I have two files and contains many Fields or columns with | (pipe) delimitor, wanted to compare both the files and get only unmatched perticular fields number. ex: first.txt 111 |abc| 230| hbc | bb2 | cs second.txt 111 |abc |230 |abn | bb2 | fp Here the different data in two... (2 Replies)
Discussion started by: prawinmca
2 Replies

4. Shell Programming and Scripting

Diff command file entries in different lines

Hello, I have two files to compare these contain some contents like this : FIle 1 : A B C E File 2 has some new entries and the old entries are in some different ordre File 2 could be like this : C E A B G I (4 Replies)
Discussion started by: ajayram
4 Replies

5. UNIX for Dummies Questions & Answers

Command to split the files based on the number of lines in it

Hello Friends, Can anyone help me for the below requirement. I am having a file called Input.txt. My requirement is first check the count that is wc -l input.txt If the result of the wc -l Input.txt is less than 10 then don't split the Input.txt file. Where as if Input.txt >= 10 the split... (12 Replies)
Discussion started by: malaya kumar
12 Replies

6. Shell Programming and Scripting

Grep command to return all the lines between one matched pattern to another.

14:15:00- abcdefghijkl. 14:30:00- abcdefghijkl. 14:35:00- abcdefghijkl. 123456789. 123456789. 14:45:00- abcdefghijkl. 14:50:00- abcdefghijkl. 123456789. 15:30:00-abcdefghijkl. (3 Replies)
Discussion started by: dev_shivv
3 Replies

7. Solaris

Grep command to return all the lines from one matched pattern to another.

For example a log file looks like below- 13:30:00- abcdefghijklhjghjghjhskj. abcdefghijkl. 14:15:00- abcdefghijkl. 14:30:00- abcdefghijkl. 14:35:00- abcdefghijkl. 123456789. 123456789. 14:45:00- abcdefghijkl. (0 Replies)
Discussion started by: dev_shivv
0 Replies

8. Shell Programming and Scripting

Show entire lines with diff command

Hi, When I run the diff command using diff -yt file1 file2, I get the output in which original lines are truncated. I tried using -W switch with diff. However, that does not produce exact output as I want. Is it possible to show entire line of file1 and file2 in diff command's output? ... (8 Replies)
Discussion started by: jal_capri
8 Replies

9. Shell Programming and Scripting

number of lines returned from a grep command

hi all, from a shell (ksh) script, i am doing a 'grep'. how do i find out the number of lines returned from that 'grep' command ?? thanks in advance. (4 Replies)
Discussion started by: cesarNZ
4 Replies

10. UNIX for Dummies Questions & Answers

Output number of rows inserted, updated...

Hi all, I am new to Unix. I have written pl/sql script to be run in Unix. I have used Merge statement and subsequently would like to know the number of rows updated or inserted. Any suggestions in this regard would be great Thanks in advance Kushal (0 Replies)
Discussion started by: kushal_cog
0 Replies
Login or Register to Ask a Question
diffmk(1)						      General Commands Manual							 diffmk(1)

NAME
diffmk - Marks differences between files SYNOPSIS
diffmk [-b] [-ab'mark'] [-ae'mark'] [-cb'mark'] [-ce'mark'] [-db'mark'] [-de'mark'] file1 file2 The diffmk command compares two versions of a file and creates a new file that marks the differences. OPTIONS
Uses mark to mark where added lines begin. Uses mark to mark where added lines end. Ignores differences that are only changes in tabs or spaces on a line. Uses mark to mark where changed lines begin. Uses mark to mark where changed lines end. Uses mark to mark where deleted lines begin. Uses mark to mark where deleted lines end. DESCRIPTION
The file1 and file2 variables are the old and new versions of the file, respectively. The diffmk command compares them and writes a new version to standard output, which can be redirected to a file. This output contains the lines of file2 marked with nroff change mark requests (.mc), or with the marks you specify with the -ab, -ae, -cb, -ce, -db, and -de options. When output containing requests is formatted with nroff, changed or inserted lines are marked by a | (vertical bar) at the right margin of each line. An * (asterisk) indicates that a line was deleted. If the DIFFMARK environment variable is defined, it names a command string that diffmk uses to compare the files. (Normally, diffmk uses the diff command.) For example, you might set DIFFMARK to diff -h in order to better handle extremely large files. EXAMPLES
To mark the differences between two versions of a text file, enter: diffmk -ab'>I:' -ae'<I' -cb'>C' -ce'<C' -db'>D' -de'<D' chap1.old chap1 >chap1.diffs This causes diffmk to create a copy of chap1 called chap1.diffs, showing differences between chap1.old and chap1. Additions of one or more lines are marked with >I and <I, changed lines are marked with >C and <C, and deletions are marked with >D and <D. To mark differences with nroff requests, enter: diffmk chap1.old chap1 > chap1.nroff This produces a copy of chap1 called chap1.nroff containing nroff change mark requests to identify text that was added to, changed, or deleted from chap1.old. To use different nroff marking requests and ignore changes in white space, enter: diffmk -b -cb'.mc %' chap1.old chap1 > chap1.nroff This imbeds commands that mark changes with % (percent sign), additions with | (the default, because no -a option is specified), and deletions with * (the default). It does not mark changes that only involve a different number of spaces or tabs between words (-b). SEE ALSO
Commands: diff(1), nroff(1) diffmk(1)