Sponsored Content
Full Discussion: Compare - 1st col of file
Top Forums Shell Programming and Scripting Compare - 1st col of file Post 302353483 by gch on Tuesday 15th of September 2009 12:10:45 PM
Old 09-15-2009
cat test2From example he shows, he needed only third file with first column that was occurring only once in both files.
If one needed full line entry from both files this will do:
Code:
for i in `cat file1 file2 | cut -f1 -d \| | sort | uniq -u`
do 
grep -h $i file1 >> fil1
grep -h $i file2 >> fil2
done

If one wants to save output, one can redirect it to some file. It still runs faster than awk and it is self-explanatory.

Last edited by gch; 09-15-2009 at 02:24 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare two col from 2 files, and output uniq from file 1

Hi, I can't find how to achive such thing, please help. I have try with uniq and comm but those command can't compare columns just whole lines, I think awk will be the best but awk is magic for me as of now. file a a1~a2~a3~a4~a6~a7~a8 file b b1~b2~b3~b4~b6~b7~b8 output 1: compare... (2 Replies)
Discussion started by: pp56825
2 Replies

2. Shell Programming and Scripting

compare two files and make 1st file same as 2nd file

I am trying to compare two file and make changes where ever its different. for example: Contents of file1 IP=192.165.89.11 NM=255.255.0.0 GW=192.165.89.1 Contents of file2 IP=192.165.89.11 NM=255.255.255.255 GW=192.165.89.1 NOTE HERE THAT NM IS DIFFERENT So i want the changes... (6 Replies)
Discussion started by: pradeepreddy
6 Replies

3. Ubuntu

Match col 1 of File 1 with col 1 File 2 and create a 3rd file

Hello, I have a 1.6 GB file that I would like to modify by matching some ids in col1 with the ids in col 1 of file2.txt and save the results into a 3rd file. For example: File 1 has 1411 rows, I ignore how many columns it has (thousands) File 2 has 311 rows, 1 column Would like to... (7 Replies)
Discussion started by: sogi
7 Replies

4. Shell Programming and Scripting

Get columns from another file for match in col 2 in 1st file

Hi, My first file has 592155 9 rs16916098 1 592156 19 rs7249604 1 592157 4 rs885156 1 592158 5 rs350067 12nd file has 9 rs16916098 0 113228129 2 4 19 rs7249604 0 58709070 4 2 2 rs17042833 0 113558750 4 2... (2 Replies)
Discussion started by: genehunter
2 Replies

5. Shell Programming and Scripting

how to add new col in a file

Hi, Experts, I have a requirement as following: my source file: a a a b b c c c c I need add one more colume as following: 1 a 2 a 3 a 1 b 2 b 1 c 2 c (4 Replies)
Discussion started by: ken002
4 Replies

6. UNIX for Advanced & Expert Users

Print line based on highest value of col (B) and repetion of values in col (A)

Hello everyone, I am writing a script to process data from the ATP world tour. I have a file which contains: t=540 y=2011 r=1 p=N409 t=540 y=2011 r=2 p=N409 t=540 y=2011 r=3 p=N409 t=540 y=2011 r=4 p=N409 t=520 y=2011 r=1 p=N409 t=520 y=2011 r=2 p=N409 t=520 y=2011 r=3 p=N409 The... (4 Replies)
Discussion started by: imahmoud
4 Replies

7. Shell Programming and Scripting

Printing from col x to end of line, except last col

Hello, I have some tab delimited data and I need to move the last col. I could hard code it, awk '{ print $1,$NF,$2,$3,$4,etc }' infile > outfile but it would be nice to know the syntax to print a range cols. I know in cut you can do, cut -f 1,4-8,11- to print fields 1,... (8 Replies)
Discussion started by: LMHmedchem
8 Replies

8. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

9. Shell Programming and Scripting

Modifying col values based on another col

Hi, Please help with this. I have several excel files (with and .xlsx format) with 10-15 columns each. They all have the same type of data but the columns are not ordered in the same way. Here is a 3 column example. What I want to do add the alphabet from column 2 to column 3, provided... (9 Replies)
Discussion started by: newbie83
9 Replies

10. UNIX for Beginners Questions & Answers

Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd

hi I have 2 file with more than 10 columns for both 1st file apple,0,0,0...... orange,1,2,3..... mango,2,4,5..... 2nd file apple,2,3,4,5,6,7... orange,2,3,4,5,6,8... watermerlon,2,3,4,5,6,abc... mango,5,6,7,4,6,def.... (1 Reply)
Discussion started by: tententen
1 Replies
TIFFReadDirectory(3T)													     TIFFReadDirectory(3T)

NAME
TIFFReadDirectory - get the contents of the next directory in an open TIFF file SYNOPSIS
#include <tiffio.h> int TIFFReadDirectory(TIFF* tif) DESCRIPTION
Read the next directory in the specified file and make it the current directory. Applications only need to call TIFFReadDirectory to read multiple subfiles in a single TIFF file-- the first directory in a file is automatically read when TIFFOpen is called. NOTES
If the library is compiled with STRIPCHOP_SUPPORT enabled, then images that have a single uncompressed strip or tile of data are automati- cally treated as if they were made up of multiple strips or tiles of approximately 8 kilobytes each. This operation is done only in-mem- ory; it does not alter the contents of the file. However, the construction of the ``chopped strips'' is visible to the application through the number of strips [tiles] returned by TIFFNumberOfStrips [TIFFNumberOfTiles]. RETURN VALUES
If the next directory was successfully read, 1 is returned. Otherwise, 0 is returned if an error was encountered, or if there are no more directories to be read. DIAGNOSTICS
All error messages are directed to the TIFFError(3T) routine. All warning messages are directed to the TIFFWarning(3T) routine. Seek error accessing TIFF directory. An error occurred while positioning to the location of the directory. Wrong data type %d for field "%s". The tag entry in the directory had an incorrect data type. For example, an ImageDescription tag with a SHORT data type. TIFF directory is missing required "%s" field. The specified tag is required to be present by the TIFF 5.0 specification, but is missing. The directory is (usually) unusable. %s: Rational with zero denominator. A directory tag has a RATIONAL value whose denominator is zero. Incorrect count %d for field "%s" (%lu, expecting %lu); tag ignored. The specified tag's count field is bad. For example, a count other than 1 for a SubFileType tag. Cannot handle different per-sample values for field "%s". The tag has SamplesPerPixel values and they are not all the same; e.g. BitsPer- Sample. The library is unable to handle images of this sort. Count mismatch for field "%s"; expecting %d, got %d. The count field in a tag does not agree with the number expected by the library. This should never happen, so if it does, the library refuses to read the directory. Invalid TIFF directory; tags are not sorted in ascending order. The directory tags are not properly sorted as specified in the TIFF 5.0 specification. This error is not fatal. Ignoring unknown field with tag %d (0x%x). An unknown tag was encountered in the directory; the library ignores all such tags. TIFF directory is missing requred "ImageLength" field. The image violates the specification by not having a necessary field. There is no way for the library to recover from this error. TIFF directory is missing requred "PlanarConfig" field. The image violates the specification by not having a necessary field. There is no way for the library to recover from this error. TIFF directory is missing requred "StripOffsets" field. The image has multiple strips, but is missing the tag that specifies the file off- set to each strip of data. There is no way for the library to recover from this error. TIFF directory is missing requred "TileOffsets" field. The image has multiple tiles, but is missing the tag that specifies the file offset to each tile of data. There is no way for the library to recover from this error. TIFF directory is missing required "StripByteCounts" field. The image has multiple strips, but is missing the tag that specifies the size of each strip of data. There is no way for the library to recover from this error. TIFF directory is missing required "StripByteCounts" field, calculating from imagelength. The image violates the specification by not hav- ing a necessary field. However, when the image is comprised of only one strip or tile, the library will estimate the missing value based on the file size. Bogus "StripByteCounts" field, ignoring and calculating from imagelength. Certain vendors violate the specification by writing zero for the StripByteCounts tag when they want to leave the value unspecified. If the image has a single strip, the library will estimate the missing value based on the file size. SEE ALSO
libtiff(3T), TIFFOpen(3T), TIFFWriteDirectory(3T), TIFFSetDirectory(3T), TIFFSetSubDirectory(3T) October 15, 1995 TIFFReadDirectory(3T)
All times are GMT -4. The time now is 04:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy