Sponsored Content
Top Forums Shell Programming and Scripting Find duplicates in column 1 and merge their lines (awk?) Post 302762419 by falcox on Monday 28th of January 2013 11:58:23 AM
Old 01-28-2013
Find duplicates in column 1 and merge their lines (awk?)

Hi,

I have a file (sorted by sort) with 8 tab delimited columns. The first column contains duplicated fields and I need to merge all these identical lines.

My input file:
Code:
comp100002	aaa	bbb	ccc	ddd	eee	fff	ggg
comp100003	aba	aba	aba	aba	aba	aba	aba
comp100003	fff	fff	fff	fff	fff	fff	fff
comp100004	xxx	xyz	xyz	xxx	xyz	xxx	xyz

My desired output file:

Code:
comp100002	aaa	bbb	ccc	ddd	eee	fff	ggg
comp100003	aba	aba	aba	aba	aba	aba	aba	fff	fff	fff	fff	fff	fff	fff
comp100004	xxx	xyz	xyz	xxx	xyz	xxx	xyz

Thanks for advice.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

duplicates lines with one column different

Hi I have the following lines in a file SANDI108085FRANKLIN WRAP 7285 SANDI109514ZIPLOC STRETCH N SEAL 7285 SANDI110198CHOICE DM 0911 SANDI111144RANDOM WEIGHT BRAND 0704 SANDI111144RANDOM WEIGHT BRAND 0738... (10 Replies)
Discussion started by: dhanamurthy
10 Replies

2. Shell Programming and Scripting

Awk to find duplicates in 2nd field

I want to find duplicates in file on 2nd field i wrote this code: nawk '{a++} END{for i in a {if (a>1) print}}' temp Could not find whats wrong with this. Appreciate help (5 Replies)
Discussion started by: pinnacle
5 Replies

3. Shell Programming and Scripting

Merge lines in a file with Awk - incorrect output

Hi, I would like: FastEthernet0/0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 output errors, 0 collisions, 0 interface resets Serial1/0:0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 0... (14 Replies)
Discussion started by: mv652
14 Replies

4. Shell Programming and Scripting

Find duplicates in the first column of text file

Hello, My text file has input of the form abc dft45.xml ert rt653.xml abc ert57.xml I need to write a perl script/shell script to find duplicates in the first column and write it into a text file of the form... abc dft45.xml abc ert57.xml Can some one help me plz? (5 Replies)
Discussion started by: gameboy87
5 Replies

5. Shell Programming and Scripting

Gawk / Awk Merge Lines based on Key

Hi Guys, After windows died on my netbook I installed Lubuntu and discovered Gawk about a month ago. After using Excel for 10+ years I'm amazed how quick and easily Gawk can process data but I'm stuck with a little problem merging data from multiple lines. I'm an SEO Consultant and provide... (9 Replies)
Discussion started by: Jamesfirst
9 Replies

6. Shell Programming and Scripting

find numeric duplicates from 300 million lines....

these are numeric ids.. 222932017099186177 222932014385467392 222932017371820032 222932017409556480 I have text file having 300 millions of line as shown above. I want to find duplicates from this file. Please suggest the quicker way.. sort | uniq -d will... (3 Replies)
Discussion started by: pamu
3 Replies

7. Shell Programming and Scripting

Find lines with matching column 1 value, retain only the one with highest value in column 2

I have a file like: I would like to find lines lines with duplicate values in column 1, and retain only one based on two conditions: 1) keep line with highest value in column 3, 2) if column 3 values are equal, retain the line with the highest value in column 4. Desired output: I was able to... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

8. Shell Programming and Scripting

Find matched patterns in a column of 2 files with different size and merge them

Hi, i have input files like below:- input1 Name Seq_ID NewID Scores MT1 A0QZX3 1.65 277.4 IVO A0QZX3 1.65 244.5 HPO A0QZX3 1.65 240.5 RgP A0Q3PP 5.32 241.0 GX1 LPSZ3S 96.1 216.9 MEL LPSS3X 4.23 204.1 LDD LPSS3X 4.23 100.2 input2 Fac AddName NewID ... (9 Replies)
Discussion started by: redse171
9 Replies

9. Shell Programming and Scripting

Find duplicates in 2 & 3rd column and their ID

with below given format, I have been trying to find out all IDs for those entries with duplicate names in 2nd and 3rd columns and their count like how many time duplication happened for any name if any, 0.237788 Aaban Aahva 0.291066 Aabheer Aahlaad 0.845814 Aabid Aahan 0.152208 Aadam... (6 Replies)
Discussion started by: busyboy
6 Replies

10. Shell Programming and Scripting

awk to Sum columns when other column has duplicates and append one column value to another with Care

Hi Experts, Please bear with me, i need help I am learning AWk and stuck up in one issue. First point : I want to sum up column value for column 7, 9, 11,13 and column15 if rows in column 5 are duplicates.No action to be taken for rows where value in column 5 is unique. Second point : For... (1 Reply)
Discussion started by: as7951
1 Replies
GRDINFO(l)																GRDINFO(l)

NAME
grdinfo - Get information about the contents of a 2-D grd file SYNOPSIS
grdinfo grdfiles [ -C ] [ -D ] [ -F ] [ -L1 ] [ -L2 ] [ -M ] [ -V ] DESCRIPTION
grdinfo reads a 2-D binary grd file and reports various statistics for the (x,y,z) data in the grdfile. The output information contains the minimum/maximum values for x, y, and z, where the min/max of z occur, the x- and y-increments, and the number of x and y nodes, and [optionally] the mean, standard deviation, and/or the median, L1 scale of z, and number of nodes set to NaN. grdfile The name of one or several 2-D grd files. OPTIONS
No space between the option flag and the associated arguments. -C Formats the report using tab-separated fields on a single line. The output is w e s n z0 z1 dx dy nx ny [ x0 y0 x1 y1 ] [ med scale ] [ mean std rms] [n_nan]. The data in brackets are output only if the corresponding options -M, -L1, -L2, and -M are used, respec- tively. -D Report grid domain and x/y-increments using dd:mm:ss[.fff] notation [Default is decimal]. Does not apply to the -C option. -F Report grid domain and x/y-increments world mapping format [Default is generic]. Does not apply to the -C option. -L1 Report median and L1 scale of z (L1 scale = 1.4826 * Median Absolute Deviation (MAD)). -L2 Report mean and standard deviation of z. -M Find and report the location of min/max z-values, and count and report the number of nodes set to NaN, if any. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. EXAMPLES
To obtain all the information about the data set in file hawaii_topo.grd, try grdinfo -L1 -L2 -M hawaii_topo.grd SEE ALSO
gmt(1gmt), grd2cpt(1gmt), grd2xyz(1gmt), grdedit(1gmt) 1 Jan 2004 GRDINFO(l)
All times are GMT -4. The time now is 01:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy