Sponsored Content
Top Forums Shell Programming and Scripting Using Diff to Compare 2 files Post 302410960 by ladyAnne on Wednesday 7th of April 2010 08:54:01 AM
Old 04-07-2010
For example say suppose these were my files:

file1:

Code:
 
Blocks Reserved,CELL,1A,,,,AGBLK,0,0,1,CELL,1A,,,,ERICSSON,GSM,07B
Blocks Reserved,CELL,1B,,,,AGBLK,2,2,1,CELL,1B,,,,ERICSSON,GSM,07B
Blocks Reserved,CELL,1C,,,,AGBLK,3,3,1,CELL,1C,,,,ERICSSON,GSM,07B

file2:

Code:
 
Blocks Reserved,CELL,1A,,,,AGBLK,5,5,1,CELL,1A,,,,ERICSSON,GSM,07B
Blocks Reserved,CELL,1B,,,,AGBLK,2,2,1,CELL,1B,,,,ERICSSON,GSM,07B
Blocks Reserved,CELL,1C,,,,AGBLK,3,3,1,CELL,1C,,,,ERICSSON,GSM,07B

Then I want my result file to display the original line from file1 and below that the line that changed in file2:

Code:
 
Blocks Reserved,CELL,1A,,,,AGBLK,0,0,1,CELL,1A,,,,ERICSSON,GSM,07B
Blocks Reserved,CELL,1A,,,,AGBLK,5,5,1,CELL,1A,,,,ERICSSON,GSM,07B

 

9 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

Compare/Diff between directories and subdirectories?

Hi, Does anybody know the cmd to compare two areas and print out the different files w/ path? I tried cmp and diff and dircmp but with no luck. Should I grep and print? For example: /aa/images/jan ..../images/feb /bb/images/jan ..../images/feb i want to print the compare,... (5 Replies)
Discussion started by: andylee80
5 Replies

3. Shell Programming and Scripting

compare 2 coloum of 2 diff files using perl script

Hi, i am new to perl scripting.. i am still learing it.. i am asked to write a perl script which should compare 2 coloums of 2 different files. if those 2 coloumn are same the script should store the both the lines in 2 diff files. these are files, file 1: 21767016 226112 char 19136520... (3 Replies)
Discussion started by: vasuki
3 Replies

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

5. Shell Programming and Scripting

compare two files, diff the result

Hi Everyone, 1.txt 00:01:01 asdf 00:33:33 1234 00:33:33 0987 00:33:33 12 00:33:33 444 2.txt vvvv|ee 444|dd33|ee dddd|ee 12|ee 3ciur|fdd the output should be: (6 Replies)
Discussion started by: jimmy_y
6 Replies

6. Shell Programming and Scripting

Shell script to compare ,diff and remove betwen 2 files

Hi Friends Need your expertise. Command to check the difference and compare 2 files and remove lines . example File1 is master copy and File2 is a slave copy . whenever i change, add or delete a record in File1 it should update the same in slave copy . Can you guide me how can i accomplish... (3 Replies)
Discussion started by: ajayram_arya
3 Replies

7. Shell Programming and Scripting

Compare two CSV files and put the difference in third file with line no,field no and diff value.

I am having two csv files i need to compare these files and the output file should have the information of the differences at the field level. For Example, File 1: A,B,C,D,E,F 1,2,3,4,5,6 File 2: A,C,B,D,E,F 1,2,4,5,5,6 out put file: (12 Replies)
Discussion started by: karingulanagara
12 Replies

8. Shell Programming and Scripting

Using Diff to compare 2 arrays

I have two arrays and they look like this: array=(`cat /local/mnt/*sys/*includes|grep -v NEW`) array2=(`cat /tmp/*sys.z |grep -v NEW`) I am trying to compare them but I need to use the diff -u command. I am not sure how to do this. I cannot just do diff -u ${array} ${array2} I cannot... (4 Replies)
Discussion started by: newbie2010
4 Replies

9. Shell Programming and Scripting

Diff 3 files, but diff only their 2nd column

Guys i have 3 files, but i want to compare and diff only the 2nd column path=`/home/whois/doms` for i in `cat domain.tx` do whois $i| sed -n '/Registry Registrant ID:/,/Registrant Email:/p' > $path/$i.registrant whois $i| sed -n '/Registry Admin ID:/,/Admin Email:/p' > $path/$i.admin... (10 Replies)
Discussion started by: kenshinhimura
10 Replies
tingea.log(7)							  MISCELLANEOUS 						     tingea.log(7)

  NAME
      tingea.log - How to set the Tingea log parameters

  DESCRIPTION
      The  Tingea  logging framework is part of the Tingea library.  In this context logging means that a pgrogram issues statements about what it
      is doing. It can do so for different purposes and at different levels of verbosity. By default logging statements are written on STDERR.

      Tingea logging provides a quick and easy way for programmers to associate verbosity levels with logging statements.  Only logging statements
      for which the verbosity level does not exceed the user-imposed threshold will be executed.  Users can easily regulate the verbosity level by
      setting the environment variable TINGEA_LOG_TAG.	Alternatively, programs may accept a command line argument.  The format accepted  by  both
      environment  variable  and command line argument is identical.  For the command line the programmer is free in choosing the option name.	It
      is customarily named -q.	The availability of such an option may vary from program to program.  However, any program that makes use  of  the
      Tingea logging facilities can be regulated with the TINGEA_LOG_TAG environment variable.	If a -q type option is present and the environment
      variable is set, then the environment variable is interpreted first followed by the -q argument.

      Tingea logging allows a programmer to assign categories to logging statements. The categories FUNCTION and DATA have a  subdivision  ranging
      from fine-grained to coarse-grained. The categorie MONITORING has a subdivision ranging from low priority to high priority.  The other cate-
      gories are unimodal. These are IO, THREAD, PROCESS, and GAUGE. Three unspecified unimodal categories are SLOT1, SLOT2, and SLOT3.  They  can
      be used to encode program-specific semantics.

      The  programmer  may  assign multiple categories to a single logging statement.  It is unusual for more than two categories to be specified.
      For example, IO and DATA at the LIST level may be combined to indicate a logging statement that provides data summaries  for  a  certain	IO
      related information. In order of granularity the DATA levels are CELL, LIST, and AGGREGRATE. If the user accepts IO logging and accepts DATA
      logging at level CELL or LIST the statement will be executed. If no IO logging is accepted or DATA logging is only accepted  at  the  AGGRE-
      GRATE level, the statement will be skipped.

      By  default,  all  categories  that are specified by the programmer need to pass the threshold specified by the user for that category.  The
      user may relax this requirement so that only one category needs to pass the user threshold. In the above example, the statement  categorized
      as both IO and DATA at LIST level will be accepted if the user specifies IO and DATA at AGGR level with OR semantics.

  SYNTAX
      The syntax of the TINGEA_LOG_TAG environment variable is described by

	 [[189x]]{<[dfgimpstABC][1-9]>*,[V]}

      which  translates to the following. An optional lead tag is followed by a concatenation of units. A unit is either a pair in [dfgimpstABC] x
      [1-9x] or the single character V.  The leading tag semantics are described further below.  The single character  V,  if  present,  specifies
      that OR semantics should be used rather than the default AND semantics. The semantics for the other units are given below.

	 d     DATA
		  1  CELL
		  2  LIST
		  3  AGGR
		  x  turned off

	 f     FUNCTION
		  1  LINE
		  2  FUNCTION
		  3  MODULE
		  4  APPLICATION
		  x  turned off

	 m     MONITORING
		  1  DEBUG
		  2  INFO
		  3  WARNING
		  4  ERROR
		  5  PANIC
		  x  turned off

	 g     GAUGE	|
	 i     IO	|
	 n     NETWORK	|
	 p     PROCESS	|  (Inter Process really)
	 t     THREAD	|______  1 on
			|	 x off
	 A     SLOT1	|
	 B     SLOT2	|
	 C     SLOT3	|

      The  leading  tag  can be used to set levels for all categories at once.	Subsequent units may then alter this intial setting.  The lead tag
      settings and their meaning are these:

	 1     d1f1m1g1i1p1s1t1A1B1C1	  # very yappy
	 9     d3f4m5gxixpxsxtxAxBxCx	  # very terse, only d f m
	 8     d3f4m5g1i1p1s1t1A1B1C1	  # less terse
	 x     dxfxmxgxixpxsxtxAxBxCx	  # silent

      All categories accept values between 1 and 9 in addition to the value x. As seen above, only a few categories contain more  than	one  level
      and no category contains more than five levels.  The rule is that if a level exceeds the maximul level available for a category it is simply
      interpreted as the maximum level.

      The GAUGE category, if set, indicates that a program may write line based progress bars or other output in which a single  line  is  accumu-
      lated  over  multiple  statements.  This	implies that a single GAUGE logging statement may not result in newline-terminated output. This is
      undesirable in case the logging stream is directed to a file that is written to by other applications as well. In that case, turn off GAUGE.
      All other categories are garantueed to result in line-terminated output, by virtue of the programmer contract.

  AUTHOR
      Stijn van Dongen.

  tingea.log 12-068						      8 Mar 2012						       tingea.log(7)
All times are GMT -4. The time now is 04:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy