Compare two text file and output the same to third file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compare two text file and output the same to third file
# 8  
Old 02-27-2012
Hi, suresh7730.

As you can see from my first post, the solution worked on my system using the utilities noted, processing the sample data you provided.

There are a number of possibilities where things could have gone awry. You can start by investigating these areas:

1) The versions of your utilities, e.g. join, and mine differ. That why I display the versions I am using,

2) Perhaps you copied the solution command incorrectly (you probably don't have the data display command specimen, but that should not affect the solution),

3) Your real data has a form that is different from the sample data you posted.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

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

3. Shell Programming and Scripting

Compare output of UNIX command and match data to text file

I am working on an outage script and I run a command from the command line which tells me the amount of generator failures in my market. The output of this command only gives me three digits to identify the site by. I have a master list of all sites in a separate file, call it list.txt. If my... (7 Replies)
Discussion started by: jbrass
7 Replies

4. UNIX for Dummies Questions & Answers

To compare two files,Output into a new file

Hi Please help me to compare two files and output into a new file file1.txt 15114933 |4001 15291649 |933502 15764675 |4316 15764678 |4316 15761974 |282501 15673104 |933505 15673577 |933505 15673098 |933505 15673096 |933505 15673092 |933505 15760705 ... (13 Replies)
Discussion started by: Ankita Talukdar
13 Replies

5. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

6. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

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

8. Shell Programming and Scripting

Compare two file & output

Hi every body i have a problem need help urgently file 1 (approx 200K entries) aaaaa bbbb cccccc dddd ffff file 2 (approx 2 million entries) aaaaa,1,ee,44,5t,6y, bbbb,3,ff,66,5u,8r, cccccc, ..... dddd, ..... eeeeee, ..... ffff, ...... (5 Replies)
Discussion started by: The_Archer
5 Replies

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

10. Shell Programming and Scripting

compare file size from a output file from a script

Hi guys, firstly I'm working on SunOS 5.10 Generic_125100-10 sun4u sparc SUNW,Sun-Fire-V240 I've made a script to compress two directory and then send them to an other server via ftp. This is working very well. Inside theis script I decide to log usefull data for troubleshooting in case of... (7 Replies)
Discussion started by: moustik
7 Replies
Login or Register to Ask a Question
dwdiff(1)						    delimited word diff program 						 dwdiff(1)

NAME
dwdiff - a delimited word diff program SYNOPSIS
dwdiff [OPTIONS] <OLD FILE> <NEW FILE> dwdiff [OPTIONS] --diff-input [<DIFF FILE>] DESCRIPTION
dwdiff is a diff program that operates at the word level instead of the line level. It is different from wdiff in that it allows the user to specify what should be considered whitespace, and in that it takes an optional list of characters that should be considered delimiters. Delimiters are single characters that are treated as if they are words, even when there is no whitespace separating them from preceding words or delimiters. dwdiff is mostly command-line compatible with wdiff. Only the --autopager, --terminal and --avoid-wraps options are not supported. The default output from dwdiff is the new text, with the deleted and inserted parts annotated with markers. Command line options are avail- able to change both what is printed, and the markers. OPTIONS
dwdiff accepts the following options (Note that all strings will first be escape expanded. All standard -escapes are supported, as well as u and U Unicode escapes): -h, --help Display a short help message. -v, --version Print version and copyright information. -d <delimiters>, --delimiters=<delimiters> Specify a list of characters to be used as delimiters. -P, --punctuation> Use punctuation characters as delimiters. The exact set of punctuation characters depends on the current locale. -W <whitespace>, --whitespace=<whitespace> Specify a list of characters to be used as whitespace. --diff-input Interpret the input as the output from diff in the Unified Diff format (usually produced by diff -u). In this case only one input file is allowed. This option allows reformating diff output with dwdiff, and is useful for example to post-process the output of svn diff. -1, --no-deleted Suppress printing of words deleted from the first file. -2, --no-inserted Suppress printing of words inserted in the second file. -3, --no-common Suppress printing of words common to both files. -L[<width>], --line-numbers[=<width>] Show line numbers at the start of each line. The line numbers displayed are the line number in the old file and the line number in the new file respectively. The optional <width> argument is the minimum number of positions per line number. -C<num>, --context=<num> Show <num> lines of context before and after each changes. A line with only -- is printed between blocks of changes. -s, --statistics Print statistics when done. The numbers printed include the number of words from in both files, the number of deleted words, the number of inserted words, and the number of changed words. The number of changed words is counted as the number of words that are removed from the first file, and the number of words that replace them from the second file. All of these numbers are also expressed as a percentage of the total number of words in the file the words came from. -i, --ignore-case Ignore differences in case when comparing words. This option is only available if the diff program that is called provides it. -I, --ignore-formatting Ignore differences in formatting of characters. This option switches to using the Unicode compatibility decomposition instead of the canonical decomposition. The compatibility decomposition discards formatting information. For example, the ligature fi will be decomposed into two separate characters for the purposes of comparison. However, also super- and subscript will be regarded equal as well as different rotations of the same character. -c[<spec>], --color[=<spec>] Color mode. The optional <spec> can be used to customize the colors. <spec> consists of [<delete>],[<insert>]. If either is omited it will be set to its default color (bright red or bright green respectively). Both parts of the <spec> consist of [<fore- ground>][:<background>]. To obtain a list of permissible color names, use the word ``list'' as <spec>. Alternatively, you can spec- ify any escape sequence to set attributes as a color by prepending e:. The standard markers for the begin and end of deleted and inserted text are suppressed, but any markers specified on the command line will still be printed. -l, --less-mode As -p but also overstrike deleted whitespace. -p, --printer Use overstriking with an underscore and bold text to emphasize changes. This is implemented by first printing the underscore or a duplicate of the character to be printed, followed by a backspace, followed by the character. On regular terminals you won't see any effect. The less(1) command will however show underlined and bold text. The standard markers for the begin and end of deleted and inserted text are suppressed, but any markers specified on the command line will still be printed. -m<num>, --match-context=<num> Use <num> words of context before and after words for matching. Words in the old text will then only match words in the new text if words surrounding them are also equal. This improves the output for dwdiff for large changes with frequently occuring words. How- ever, using context requires more disk space and more processing time. The default value is 1. Set this option to 0 to revert to the pre 1.5 behavior. --aggregate-changes Allow multiple close changes to be treated as one change, if context words are used (see --match-context). This option reduces the processing time as the changes reported by the diff program are not post-processed to give more precise results. -A <algorithm>, --algorithm=<algorithm> Select the algorithm to be used for determining differences. There are three possible values for algorithm: best, which tries to find the minimal set of changes, normal, which trades some optimality for speed, and fast, which assumes that the input is large and contains few changes. By default the normal algorithm is used. -S[<marker>], --paragraph-separator[=<marker>] Show insertion or deletion of blocks of lines with only whitespace characters. A special marker is inserted into the output to indicate these blocks. The default marker is <-->. --wdiff-output Create wdiff compatible output. The dwdiff program uses a different output algorithm, which provides a more intuitive output. -w <string>, --start-delete=<string> Specify a string to mark begin of deleted text. -x <string>, --stop-delete=<string> Specify a string to mark end of deleted text. -y <string>, --start-insert=<string> Specify a string to mark begin of inserted text. -z <string>, --stop-insert=<string> Specify a string to mark end of inserted text. -R, --repeat-markers Repeat the begin and end markers at the start and end of line if a change crosses a newline. A single dash (-) as a file can be used to denote standard input. Only one file can be read from standard input. To stop dwdiff from inter- preting file names that start with a dash as options, one can specify a double dash (--) after which dwdiff will interpret any following arguments as files to read. BUGS
If you think you have found a bug, please check that you are using the latest version of dwdiff [http://os.ghalkes.nl/dwdiff.html]. When reporting bugs, please include a minimal example that demonstrates the problem. AUTHOR
G.P. Halkes <dwdiff@ghalkes.nl> COPYRIGHT
Copyright (C) 2006-2011 G.P. Halkes and others dwdiff is licensed under the GNU General Public License version 3. For more details on the license, see the file COPYING in the documentation directory. On Un*x systems this is usually /usr/share/doc/dwdiff-2.0.4. SEE ALSO
dwfilter(1), wdiff(1), diff(1) Version 2.0.4 12-06-2012 dwdiff(1)