01-10-2012
merge two column multiple files into one
Hi
I have multiple files each with two columns and I need to combine all those file into a tab delimited file. (multiple entry with same name separated by a comma)
The content of the files are as follows:
---
file1.txt:
name var1
aaa xx
aaa gg
bbb yy
ddd zz
---
file2.txt
name var2
bbb mm
ccc nn
ddd pp
ddd qq
----
file3.txt
name var3
aaa uu
ddd vv
eee ww
fff tt
fff uu
---------
I need to combine all these file into a tab delimited file in such a way that the output looks like follows:
|
name \t var1 \t var2 \t var3 |
aaa \t xx, gg \t - \t uu |
bbb \t yy \t mm \t - |
ccc \t zz \t nn \t - |
ddd \t - \t pp,qq \t vv |
eee \t - \t - \t ww |
fff \t - \t - \t tt,uu |
* \t shows tab delimited space.
I was wondering how to do this in unix. I can do the same in other language but because of efficiency issue I was looking to unix as a potential rescuer.
Thanks for ur help
Last edited by mary271; 01-10-2012 at 06:50 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to join two files based on first column of both files.If first column of first file matches with the first column of second file, then the lines should be merged together and go for next line to check. It is something like:
File one:
110001 abc efd
110002 fgh dfg
110003 ... (10 Replies)
Discussion started by: apjneeraj
10 Replies
2. UNIX for Dummies Questions & Answers
I have 100 data files labelled 250.1.txt through 250.100.txt. The second column of the data files partially match (there is about %90 overlap). Each data file has 4 columns.
I want the merge all these text files by the matching values in the second column. In the output, the first column should... (1 Reply)
Discussion started by: evelibertine
1 Replies
3. Shell Programming and Scripting
Hi ,
I have few files which contains user name and data transfer rate in MBs and this data is collected for year and for each month report is saved in 12 different files I have to merge all the files to prepare the final report
Files are as below
Similarly I have 10 more files ... (5 Replies)
Discussion started by: pratapsingh
5 Replies
4. Shell Programming and Scripting
Hi,
Can anyone suggest quick way to get desired output?
Sample input file content:
A 12 9
A -0.3 2.3
B 1.0 -4
C 34 1000
C -111 900
C 99 0.09
Output required:
A 12 9 -0.3 2.3
B 1.0 -4
C 34 1000 -111 900 99 0.09
Thanks (3 Replies)
Discussion started by: cbm_000
3 Replies
5. Shell Programming and Scripting
I have two text files that look something like this:
A:B:C 123
D:E:F 234
G:H:I 345
J:K:L 123
M:N:O 456
P:Q:R 567
A:B:C 456
D:E:F 567
G:H:I 678
J:K:L 456
M:N:O 789
P:Q:R 890
I want to find the line where the first column matches and then combine the second columns into a single... (8 Replies)
Discussion started by: pbluescript
8 Replies
6. UNIX for Dummies Questions & Answers
Hi all,
I'm looking for a way to merge multiple columns (from one file) into a single column in an output file.
The file I have looks somewhat like this:
@HWI-ST212 1:N:0 AGTCCTACCGGGAGT + @@@DDDDDHHHHHII
@HWI-ST212 1:N:0 CGTTTAAAAATTTCT + @;@B;DDDDH?:F;F... (4 Replies)
Discussion started by: Vnguyen
4 Replies
7. Shell Programming and Scripting
Hi Friends,
I have a file
file1.txt
1|ABC|3|jul|dhj
2|NHU|4|kil|eu
3|hjd|34|hfd|43
file2.txt
1||3|KING|dhj
2|NHU||k|
3|hjd|34|hd|43
i want to merge file1.txt file2.txt based on the column null values in file2.txif there are any nulls in column values , (5 Replies)
Discussion started by: i150371485
5 Replies
8. Shell Programming and Scripting
Hello all,
I am quite new in linux shell scripting and I have this issue.
I ve got some files including measurements taken every 10minutes for a whole day.
File name format is: 00.00, 00.10, 00.20,....23.50
File structure is: x | y | temperature
x and y is the same in all files (same... (12 Replies)
Discussion started by: atzounis
12 Replies
9. Shell Programming and Scripting
Hi,
Please excuse for often requesting queries and making R&D, I am trying to work out a possibility where i have two files field separated by pipe and another file containing only one field where there is no matching columns, Could you please advise how to merge two files.
$more... (3 Replies)
Discussion started by: karthikram
3 Replies
10. UNIX for Dummies Questions & Answers
Hi all,
I have two separate csv files(comma delimited) file 1 and file 2.
File 1 contains
PAN,NAME,Salary
AAAAA5467D,Raj,50000
AAFAC5467D,Ram,60000
BDCFA5677D,Kumar,90000
File 2 contains
PAN,NAME,Dept,Salary
ASDFG6756T,Karthik,ABC,450000
QWERT8765Y,JAX,CDR,780000... (5 Replies)
Discussion started by: Nivas
5 Replies
LEARN ABOUT OSF1
inet_pton
inet_pton(3) Library Functions Manual inet_pton(3)
NAME
inet_pton - Converts a text string to a numeric address
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <arpa/inet.h>
int inet_pton ( int af, const char *src, void *dst) ;
PARAMETERS
Specifies the address family. Valid values are AF_INET for an Internet Protocol Version 4 (IPv4) address and AF_INET6 for an IPv6 address.
Points to the address text string to be converted. Points to a buffer that is to contain the numeric address.
DESCRIPTION
The use of this routine is deprecated. Use the getaddrinfo(3) routine instead; it is also protocol-independent.
The inet_pton() function converts a text string to a numeric value in Internet network-byte order.
If the af parameter is AF_INET, the function accepts a string in the standard IPv4 dotted-decimal form: ddd.ddd.ddd.ddd
In this format, ddd is a one to three digit decimal number between 0 and 255.
If the af parameter is AF_INET6, the function accepts a string in the following form: x:x:x:x:x:x:x:x
In this format, x is hexadecimal value of a 16-bit piece of the address.
IPv6 addresses can contain long strings of zero (0) bits. To make it easier to write these addresses, you can use double colon characters
(::) one time in an address to represent 1 or more 16-bit groups of zeros.
For mixed IPv4 and IPv6 environments, the following form is also accepted: x:x:x:x:x:x:ddd.ddd.ddd.ddd
In this form, x is hexadecimal value of a 16-bit piece of the address and ddd is a one to three digit decimal value between 0 and 255 that
represents the IPv4 address. See RFC 2373 for more information on IPv6 addressing formats.
The calling application is responsible for ensuring that the buffer referred to by the dst parameter is large enough to hold the numeric
address. AF_INET addresses require 4 bytes and AF_INET6 addresses require 16 bytes.
RETURN VALUES
Upon successful completion, the inet_pton() function returns 1. If the input string is not a valid IPv4 dotted-decimal string or a valid
IPv6 address string, the function returns 0. If any other error occurs, the function returns -1.
ERRORS
If the inet_pton() routine call fails, errno is set to one of the following values: The address family specified in the af parameter is
unknown.
RELATED INFORMATION
Functions: getaddrinfo(3), inet_ntop(3).
RFC 2373, IP Version 6 Addressing Architecture delim off
inet_pton(3)