Sponsored Content
Full Discussion: Diff output to text file
Top Forums Shell Programming and Scripting Diff output to text file Post 302957683 by Badhrish on Wednesday 14th of October 2015 03:59:52 AM
Old 10-14-2015
Diff output to text file

Hi All,

When I write the diff command output(side by side format) to a file and viewed on the desktop using any text editor(say Notepad) the format of the output layout isn't the same as it should be, though "Wordwrap" option is disabled. Which means left and right records are not on same line. Please help me out on how to overcome this.

FILE1:
Code:
ISA|00|          |00|          |21|ABCD           |ZZ|DEFG           |150813|0643|U|00401|000002469|0|P|>~
GS|PD|ABCD|DEFG|20150813|06431488|2469|X|004010~
ST|852|0001~
ZA|BS|0|AA~
ZA|HL|0|AA~
ZA|LS|0|AA~
ZA|MS|0|AA~
ZA|Q1|0|AA~
ZA|Q2|0|AA~

FILE2:
Code:
ISA|00|          |00|          |21|ABCD           |ZZ|DEFG           |150813|0643|U|00401|000002469|0|P|>~
GS|PD|ABCD|DEFG|20150813|06431488|2469|X|004010~
ST|852|0001~
ZA|BS|0|EA~
ZA|HL|0|EA~
ZA|LS|0|EA~
ZA|MS|0|EA~
ZA|Q1|0|EA~
ZA|Q2|0|EA~

Code:
diff -y --width=220 FILE[1-2]  >> Testcompare.txt

Output viewed as:
Code:
ISA|00|          |00|          |21|ABCD            |ZZ|DEFG           |150813|0643|U|00401|000002469|0|P|>~
														ISA|00|          |00|          |21|ABCD            |ZZ|DEFG           |150813|0643|U|00401|000002469|0|P|>~
														
GS|PD|ABCD|DEGF|20150813|06431488|2469|X|004010~
														GS|PD|ABCD|DEFG|20150813|06431488|2469|X|004010~
														
ST|852|0001~
														ST|852|0001~														
														
ZA|BS|0|AA~
													     |	ZA|BS|0|EA~
														
ZA|HL|0|AA~
													     |	ZA|HL|0|EA~
														
ZA|LS|0|AA~
													     |	ZA|LS|0|EA~
														
ZA|MS|0|AA~
													     |	ZA|MS|0|EA~
														
ZA|Q1|0|AA~
													     |	ZA|Q1|0|EA~
														
ZA|Q2|0|AA~
													     |	ZA|Q2|0|EA~


Last edited by Badhrish; 10-14-2015 at 06:16 AM..
 

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. Shell Programming and Scripting

Compare two files and output diff to third file

I have made several attempts to read two files of ip addresses and eliminate records from file1 that are in file2. My latest attempt follows. Everything works except my file3 is exactly the same as file1 and it should not be. # !/usr/bin/bash # # NoInterfaces # Utility will create a file... (8 Replies)
Discussion started by: altamaha
8 Replies

3. Shell Programming and Scripting

Ping text file of ip addressese and output to text file

I am basically a scripting noob, I have some programming logic, and I wouldn't post here if my 3 hours of searching actually found something. So far this is what I have: " #! /bin/ksh List=./pinglist1.txt cat $List | while read ip do Pingable="" ping $ip -n 2 | awk '/100%/ {print... (11 Replies)
Discussion started by: Lasthitlarry
11 Replies

4. UNIX for Dummies Questions & Answers

Diff creating special characters in output file

Hi I am comparing 2 files (using diff command) with numerical data in them. In the output file I want only the differences which are in file2 but not in file1. Although I am getting the diffences i am also getting special characters in the output file which i do not want. Can somebody help... (2 Replies)
Discussion started by: ashu_r2001
2 Replies

5. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 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. 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

8. 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

9. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

10. Shell Programming and Scripting

Trying to use diff output to compare to a separate file

I have two files: smw:/working/iso_testing # cat a QConvergeConsoleCLI-1.1.03-49.x86_64.rpm aaa_base-13.2+git20140911.61c1681-1.3.i586.rpm acpica-20140724-2.1.2.i586.rpm test.rpm smw:/working/iso_testing # cat b QConvergeConsoleCLI-1.1.03-49.x86_64.rpm... (12 Replies)
Discussion started by: jedlund21
12 Replies
Algorithm::DiffOld(3)					User Contributed Perl Documentation				     Algorithm::DiffOld(3)

NAME
Algorithm::DiffOld - Compute `intelligent' differences between two files / lists but use the old (<=0.59) interface. NOTE
This has been provided as part of the Algorithm::Diff package by Ned Konz. This particular module is ONLY for people who HAVE to have the old interface, which uses a comparison function rather than a key generating function. Because each of the lines in one array have to be compared with each of the lines in the other array, this does M*N comparisions. This can be very slow. I clocked it at taking 18 times as long as the stock version of Algorithm::Diff for a 4000-line file. It will get worse quadratically as array sizes increase. SYNOPSIS
use Algorithm::DiffOld qw(diff LCS traverse_sequences); @lcs = LCS( @seq1, @seq2, $comparison_function ); $lcsref = LCS( @seq1, @seq2, $comparison_function ); @diffs = diff( @seq1, @seq2, $comparison_function ); traverse_sequences( @seq1, @seq2, { MATCH => $callback, DISCARD_A => $callback, DISCARD_B => $callback, }, $comparison_function ); COMPARISON FUNCTIONS
Each of the main routines should be passed a comparison function. If you aren't passing one in, use Algorithm::Diff instead. These functions should return a true value when two items should compare as equal. For instance, @lcs = LCS( @seq1, @seq2, sub { my ($a, $b) = @_; $a eq $b } ); but if that is all you're doing with your comparison function, just use Algorithm::Diff and let it do this (this is its default). Or: sub someFunkyComparisonFunction { my ($a, $b) = @_; $a =~ m{$b}; } @diffs = diff( @lines, @patterns, &someFunkyComparisonFunction ); which would allow you to diff an array @lines which consists of text lines with an array @patterns which consists of regular expressions. This is actually the reason I wrote this version -- there is no way to do this with a key generation function as in the stock Algorithm::Diff. perl v5.18.2 2006-07-30 Algorithm::DiffOld(3)
All times are GMT -4. The time now is 02:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy