Sponsored Content
Top Forums Shell Programming and Scripting Compare selected columns from a file and print difference Post 302335488 by vgersh99 on Sunday 19th of July 2009 06:02:11 PM
Old 07-19-2009
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

---------- Post updated at 06:02 PM ---------- Previous update was at 05:41 PM ----------

nawk -f king.awk file1 file

king.awk:
Code:
BEGIN {
  FS=" *[|] *"
  OFS="|"
}
{ idx =$2 OFS $3}
FNR==NR {
   f1[idx]= $0
   next
}
idx in f1 { delete f1[idx];next}
1
END {
  for(i in f1)
    print f1[i]
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare 2 file and print difference in the third file URG PLS

Hi I have two files in unix. I need to compare two files and print the differed lines in other file Eg file1 1111 2222 3333 file2 1111 2222 3333 4444 5555 newfile 4444 5555 Thanks In advance (3 Replies)
Discussion started by: evvander
3 Replies

2. Shell Programming and Scripting

shell script(Preferably awk or sed) to print selected number of columns from each row

Hi Experts, The question may look very silly by seeing the title, but please have a look at it clearly. I have a text file where the first 5 columns in each row were supposed to be attributes of a sample(like sample name, number, status etc) and the next 25 columns are parameters on which... (3 Replies)
Discussion started by: ks_reddy
3 Replies

3. Shell Programming and Scripting

compare two columns of different files and print the matching second file..

Hi, I have two tab separated files; file1: S.No ddi fi cu o/l t+ t- 1 0.5 0.6 o 0.1 0.2 2 0.2 0.3 l 0.3 0.4 3 0.5 0.8 l 0.1 0.6 ... (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

4. Shell Programming and Scripting

Compare two columns in two files and print the difference

one file . . importing table employee 119 . . importing table jobs 1 2nd file . . importing table employee 120 . . importing table jobs 1 and would like... (2 Replies)
Discussion started by: jhonnyrip
2 Replies

5. Shell Programming and Scripting

Compare selected columns of two files and print whole line with mismatch

hi! i researched about comparing two columns here and got an answer. but after examining my two files, i found out that the first columns of the two files are not unique with each other. all i want to compare is the 2nd and 3rd column. FILE 1: ABS 456 315 EBS 923 163 JYQ3 654 237 FILE 2:... (1 Reply)
Discussion started by: engr.jay
1 Replies

6. Shell Programming and Scripting

compare two files, selected columns only

hi! i have two files that looks like this file 1: ABS 123 456 BCDG 124 542 FGD 459 762 file 2: ABS 132 456 FGD 459 762 output would be: from file1: ABS 132 456 BCDG 124 542 from file 2: ABS 132 456 (4 Replies)
Discussion started by: kingpeejay
4 Replies

7. Shell Programming and Scripting

awk compare specific columns from 2 files, print new file

Hello. I have two files. FILE1 was extracted from FILE2 and modified thanks to help from this post. Now I need to replace the extracted, modified lines into the original file (FILE2) to produce the FILE3. FILE1 1466 55.27433 14.72050 -2.52E+03 3.00E-01 1.05E+04 2.57E+04 1467 55.27433... (1 Reply)
Discussion started by: jm4smtddd
1 Replies

8. Shell Programming and Scripting

Compare columns of multiple files and print those unique string from File1 in an output file.

Hi, I have multiple files that each contain one column of strings: File1: 123abc 456def 789ghi File2: 123abc 456def 891jkl File3: 234mno 123abc 456def In total I have 25 of these type of file. (5 Replies)
Discussion started by: owwow14
5 Replies

9. Shell Programming and Scripting

[Solved] awk compare two different columns of two files and print all from both file

Hi, I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this File1 1 rs1 abc 3 rs4 xyz 1 rs3 stu File2 1 kkk rs1 AA 10 1 aaa rs2 DD 20 1 ccc ... (2 Replies)
Discussion started by: justinjj
2 Replies

10. Shell Programming and Scripting

Compare 2 columns from the same file and print a value depending on the result

Hello Unix gurus, I have a file with this format (example values): label1 1 0 label2 1 0 label3 0.4 0.6 label4 0.5 0.5 label5 0.1 0.9 label6 0.9 0.1 in which: column 1 is a row label column 2 and 3 are values I would like to do a simple operation on this table and get the... (8 Replies)
Discussion started by: ksennin
8 Replies
QGLColormap(3qt)														  QGLColormap(3qt)

NAME
QGLColormap - Used for installing custom colormaps into QGLWidgets SYNOPSIS
#include <qglcolormap.h> Public Members QGLColormap () QGLColormap ( const QGLColormap & map ) ~QGLColormap () QGLColormap & operator= ( const QGLColormap & map ) bool isEmpty () const int size () const void detach () void setEntries ( int count, const QRgb * colors, int base = 0 ) void setEntry ( int idx, QRgb color ) void setEntry ( int idx, const QColor & color ) QRgb entryRgb ( int idx ) const QColor entryColor ( int idx ) const int find ( QRgb color ) const int findNearest ( QRgb color ) const DESCRIPTION
The QGLColormap class is used for installing custom colormaps into QGLWidgets. QGLColormap provides a platform independent way of specifying and installing indexed colormaps into QGLWidgets. QGLColormap is especially useful when using the OpenGL color-index mode. Under X11 you must use an X server that supports either a PseudoColor or DirectColor visual class. If your X server currently only provides a GrayScale, TrueColor, StaticColor or StaticGray visual, you will not be able to allocate colorcells for writing. If this is the case, try setting your X server to 8 bit mode. It should then provide you with at least a PseudoColor visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode. Under Windows the size of the colormap is always set to 256 colors. Note that under Windows you can also install colormaps in child widgets. This class uses explicit sharing (see Shared Classes). Example of use: #include <qapplication.h> #include <qglcolormap.h> int main() { QApplication a( argc, argv ); MySuperGLWidget widget( 0 ); // A QGLWidget in color-index mode QGLColormap colormap; // This will fill the colormap with colors ranging from // black to white. for ( int i = 0; i < colormap.size(); i++ ) colormap.setEntry( i, qRgb( i, i, i ) ); widget.setColormap( colormap ); widget.show(); return a.exec(); } See also QGLWidget::setColormap(), QGLWidget::colormap(), Graphics Classes, and Image Processing Classes. MEMBER FUNCTION DOCUMENTATION
QGLColormap::QGLColormap () Construct a QGLColormap. QGLColormap::QGLColormap ( const QGLColormap & map ) Construct a shallow copy of map. QGLColormap::~QGLColormap () Dereferences the QGLColormap and deletes it if this was the last reference to it. void QGLColormap::detach () Detaches this QGLColormap from the shared block. QColor QGLColormap::entryColor ( int idx ) const Returns the QRgb value in the colorcell with index idx. QRgb QGLColormap::entryRgb ( int idx ) const Returns the QRgb value in the colorcell with index idx. int QGLColormap::find ( QRgb color ) const Returns the index of the color color. If color is not in the map, -1 is returned. int QGLColormap::findNearest ( QRgb color ) const Returns the index of the color that is the closest match to color color. bool QGLColormap::isEmpty () const Returns TRUE if the colormap is empty; otherwise returns FALSE. A colormap with no color values set is considered to be empty. QGLColormap &; QGLColormap::operator= ( const QGLColormap & map ) Assign a shallow copy of map to this QGLColormap. void QGLColormap::setEntries ( int count, const QRgb * colors, int base = 0 ) Set an array of cells in this colormap. count is the number of colors that should be set, colors is the array of colors, and base is the starting index. void QGLColormap::setEntry ( int idx, QRgb color ) Set cell at index idx in the colormap to color color. void QGLColormap::setEntry ( int idx, const QColor & color ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Set the cell with index idx in the colormap to color color. int QGLColormap::size () const Returns the number of colorcells in the colormap. SEE ALSO
http://doc.trolltech.com/qglcolormap.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qglcolormap.3qt) and the Qt version (3.3.8). Trolltech AS 2 February 2007 QGLColormap(3qt)
All times are GMT -4. The time now is 09:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy