Sponsored Content
Full Discussion: Processing diff output
Top Forums Shell Programming and Scripting Processing diff output Post 302767385 by durden_tyler on Wednesday 6th of February 2013 06:39:27 PM
Old 02-06-2013
Quote:
Originally Posted by stevensw
How to get diff to not print the chevrons and the dashes? In this case the differences are all single line differences.
...
It's difficult to figure out what *exactly* you want without a concrete example. Please do post if you have one.

Maybe the diff output for your files with single-line differences looks like this?

Code:
$
$ cat f74
this is line 1
this is line 2
this is line 3
this is line 4
this is line 5
$
$
$ cat f75
this is line 1
this is line 2
this is line 30
this is line 4
this is line 5
$
$
$ diff f74 f75
3c3
< this is line 3
---
> this is line 30
$
$

You could process them further like so -

Code:
$
$ # print lines with no chevrons and dashes
$
$ diff f74 f75 | grep "^[^-]" | sed 's/^[><]//'
3c3
 this is line 3
 this is line 30
$
$

"grep" removes the lines that start with a dash ("-").
And thereafter, sed removes the chevrons (if present) from the remaining lines.

Not sure what you meant by this:

Quote:
Originally Posted by stevensw
...Also the first few lines don't matter. How to get the output to always exclude the first few lines?...
In the example above, if we exclude the first few lines, there will be nothing to display. There are only 4 lines in the actual diff output.

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

diff 2 files; output diff's to 3rd file

Hello, I want to compare two files. All records in file 2 that are not in file 1 should be output to file 3. For example: file 1 123 1234 123456 file 2 123 2345 23456 file 3 should have 2345 23456 I have looked at diff, bdiff, cmp, comm, diff3 without any luck! (2 Replies)
Discussion started by: blt123
2 Replies

2. UNIX for Dummies Questions & Answers

diff output

I have two CSV files and I would like to create a third CSV file containing the differences between the two. I understand the diff command can be used to list differences between two files. My problem is that when I pipe the output into a third CSV file, the line numbers and other formatting... (3 Replies)
Discussion started by: paulp
3 Replies

3. Shell Programming and Scripting

Is there a way to limit DIFF output

Hello is there a way to limit the number of lines output by the DIFF command? I tried -C 200 ect and -c but it continues to print out the whole huge file. Reason needed is i'm trying to do alot of DIFFs on a long list of files and would like to only get back an indicator which files are... (2 Replies)
Discussion started by: bobk544
2 Replies

4. Shell Programming and Scripting

Formatting the output from diff

Hi, i need to display the mismatches from two files.The output what is get is the entire rows which mismatch from file 1 are displayed first and the corresponding rows from file 2 are displayed below it. Sample output: From Test Run 1 - The row count of file2.txt is 23 From Test Run 1 -... (9 Replies)
Discussion started by: ragavhere
9 Replies

5. Shell Programming and Scripting

Format diff output

I need to compare two directories with tab separated files. I'm using diff to do this. diff output doesn't identify which column values are different, it just tells which lines are different. Is there any way to format diff output. Thanks f1.txt 210 998877 phone 9981128209 add 111 nw st.... (2 Replies)
Discussion started by: blackjack101
2 Replies

6. Shell Programming and Scripting

diff output next to each other

I have two files to compare, but diff output doesn't give me decent output I want. The portion of the two files are shown below. file 1) Authorize <1> Transaction Database Slave 3 <1> CPM HTTP Proxy Server <1> SSP (TDB Server) <1> CPM Application Authorization <7> CPM Script... (5 Replies)
Discussion started by: Daniel Gate
5 Replies

7. Shell Programming and Scripting

Tweaking the output of diff

hello everyone, I am trying to compare two files and have the result in a new files. When I used diff I am getting the header, '<' and '>' in my result which I don't want to have it in my output file. :wall: opt/sam/input: diff file1.txt file2.txt 1,20d0 < 16,ZA, < ZJ,08, < Z7,03, Any... (1 Reply)
Discussion started by: siteregsam
1 Replies

8. UNIX for Dummies Questions & Answers

What does this diff output mean?

35d34 < What does that mean in diff? (3 Replies)
Discussion started by: glev2005
3 Replies

9. UNIX for Dummies Questions & Answers

Output formatting for diff -y

Hi, I wasn't sure whether to post this in the dummies or expert section, here's what I'm trying to do, but I suspect I'm missing the boat and should perhaps be using some of diff's builtin output functionality. diff -yb --suppress-common-lines file1.js file2.js >> ~/results.txt When I... (5 Replies)
Discussion started by: Buckaroo Banzai
5 Replies

10. Shell Programming and Scripting

Help with diff output

I am running diff between two directories dir1 and dir2. diff --exclude --recursive --brief -b dir1 dir2 The output of the above command is Files dir1/java/abc/bcd/abc9991.java and dir2/java/abc/bcd/abc9991.java differ Files dir1/java/abc/bcd/abc9933.java and... (11 Replies)
Discussion started by: gaurav99
11 Replies
DIFFSTAT(1)						      General Commands Manual						       DIFFSTAT(1)

NAME
diffstat - make histogram from diff-output USAGE
diffstat [options] [file-specifications] SYNOPSIS
This program reads the output of diff and displays a histogram of the insertions, deletions, and modifications per-file. DESCRIPTION
Diffstat is a program that is useful for reviewing large, complex patch files. It reads from one or more input files which contain output from diff, producing a histogram of the total lines changed for each file referenced. If the input filename ends with .bz2, .Z or .gz, diffstat will read the uncompressed data via a pipe. Diffstat recognizes the most popular types of output from diff: unified preferred by the patch utility. context best for readability, but not very compact. default not good for much, but simple to generate. Diffstat detects the lines that are output by diff to tell which files are compared, and then counts the markers in the first column that denote the type of change (insertion, deletion or modification). These are shown in the histogram as "+", "-" and "!" characters. If no filename is given on the command line, diffstat reads the differences from the standard input. OPTIONS
-c prefix each line of output with "#", making it a comment-line for shell scripts. -f format specify 0 for concise, 1 for normal output. -k suppress the merging of filenames in the report. -n number specify the minimum width used for filenames. If you don't specify this, diffstat uses the length of the longest filename, after stripping common prefixes. -p number override the logic that strips common pathnames, simulating the patch "-p" option. -u suppress the sorting of filenames in the report. -V prints the current version number -w number specify the maximum width of the histogram. The plot will never be shorter than 10 columns, just in case the filenames get too large. ENVIRONMENT
Diffstat runs in a portable UNIX(R) environment. FILES
Diffstat is a single binary module, which uses no auxiliary files. BUGS
Diffstat makes a lot of assumptions about the format of a diff file. There's no easy way to determine the degree of overlap between the "before" and "after" displays of modified lines. SEE ALSO
diff (1). AUTHOR
Thomas Dickey <dickey@invisible-island.net>. DIFFSTAT(1)
All times are GMT -4. The time now is 02:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy