Sponsored Content
Top Forums Shell Programming and Scripting Merge columns of different files Post 302582644 by polsum on Friday 16th of December 2011 04:43:42 PM
Old 12-16-2011
Merge columns of different files

Hi,

I have tab limited file 1

Quote:
a 455
b 443
c 6655
d 554
e 6
and tab limited file 2
Quote:
a 56
b 5
x 678
The output should contain common first column vales and corresponding 2nd column values; AND also unique first column value with corresponding 2nd column value of the file that contains it and 0 for the second file.

the output should be:

Quote:
a 455 56
b 443 5
c 6655 0
d 554 0
e 6 0
x 0 678
thanks in advance.Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compare columns from 2 files and merge

Dear all, Being new to Unix i have a problem. I have 2 files: File 1: 118,1,0,2,3,0,5,0.3,0,0.3,0.6,1 118,2,1,2,2,0,5,0.4,0,0.4,0.4,1 118,4,2,0,3,0,5,0.7,0,0.3,0.6,1 118,6,4,1,0,0,5,0.8,0,0.2,0,1 File 2: 118,1,BFGL-NGS-109695,3610326,0,18,1,0.556,0.389,0.056,0.25,0.8183... (2 Replies)
Discussion started by: samwilkinson
2 Replies

2. Shell Programming and Scripting

merge the two files which has contain columns

Hi may i ask how to accomplish this task: I have 2 files which has multiple columns first file 1 a 2 b 3 c 4 d second file 14 a 9 .... 13 b 10.... 12 c 11... 11 d 12... I want to merge the second file to first file that will looks like this ... (2 Replies)
Discussion started by: jao_madn
2 Replies

3. UNIX for Dummies Questions & Answers

Merge two files with two columns being similar

Hi everyone. How can I merge two files, where each file has 2 columns and the first columns in both files are similar? I want all in a file of 4 columns; join command removes the duplicate columns. 1 Dave 2 Mark 3 Paul 1 Apple 2 Orange 3 Grapes to get it like this in the 3rd file:... (9 Replies)
Discussion started by: Atrisa
9 Replies

4. Shell Programming and Scripting

Merge two files matching columns

Hi! I need to merge two files when col1 (x:x:x) matching and adds second column from file1.txt. # cat 1.txt aaa;a12 bbb;b13 ccc;c33 ddd;d55 eee;e11 # cat 2.txt bbb;b55;34444;d55 aaa;a15;35666;a44 I try with this awk and I get succesfully first column from 1.txt: # awk -F";"... (2 Replies)
Discussion started by: fhluque
2 Replies

5. UNIX for Dummies Questions & Answers

Merge columns from multiple files

Hi all, I've searched the web for a long time trying to figure out how to merge columns from multiple files. I know paste will append columns like so: paste file1 file2 file3 file4 file5 ... But this becomes inconvenient when you want to append a large number of files into a single file. ... (2 Replies)
Discussion started by: torchij
2 Replies

6. Shell Programming and Scripting

Merge columns on different files

Hello, I have two files that have this format: file 1 86.82 0.00 86.82 43.61 86.84 0.00 86.84 43.61 86.86 0.00 86.86 43.61 86.88 0.00 86.88 43.61 file 2 86.82 0.22 86.84 0.22 86.86 0.22 86.88 0.22 I would like to merge these two files such that the final file looks like... (5 Replies)
Discussion started by: kayak
5 Replies

7. Shell Programming and Scripting

Merge 2 files with one reference columns

Hi All Source1 servername1,patchid1 servername1,patchid2 servername1,patchid3 servername2,patchid1 servername2,patchid2 servername3,patchid4 servername3,patchid5 Source2 servername1,appname1 servername1,appname2 servername1,appname3 servername2,appname1 servername2,appname2... (13 Replies)
Discussion started by: mv_mv
13 Replies

8. Shell Programming and Scripting

Merge columns from multiple files

Hello and Good day I have a lot of files with same number of rows and columns.$2 and $3 are the same in all files . I need to merge $2,$3,$6 from first file and $6 from another files. File1: $1 $2 $3 $4 $5 $6... (8 Replies)
Discussion started by: ali.seifaddini
8 Replies

9. Shell Programming and Scripting

Merge files based on columns

011111123444 1234 1 20000 011111123444 1235 1 30000 011111123446 1234 3 40000 011111123447 1234 4 50000 011111123448 1234 3 50000 File2: 011111123444,Rsttponrfgtrgtrkrfrgtrgrer 011111123446,Rsttponrfgtrgtr 011111123447,Rsttponrfgtrguii 011111123448,Rsttponrfgtrgtjiiu I have 2 files... (4 Replies)
Discussion started by: vinus
4 Replies

10. Shell Programming and Scripting

Merge specific columns of two files

Hello, I have two tab delimited text files. Both files have the same number of rows but not necessarily the same number of columns. The column headers look like, File 1: f0order CVorder Name f0 RI_9 E99 E199 E299 E399 E499 E599 E699 E799 E899 E999 File 2:... (9 Replies)
Discussion started by: LMHmedchem
9 Replies
pr(1)							      General Commands Manual							     pr(1)

NAME
pr - print files SYNOPSIS
[options] [files] DESCRIPTION
The command prints the named files on the standard output. If file is or if no files are specified, the standard input is assumed. By default, the listing is separated into pages, each headed by the page number, a date and time, and the name of the file. By default, columns are of equal width, separated by at least one space; lines that do not fit are truncated. If the option is used, lines are not truncated and columns are separated by the separation character. If the standard output is associated with a terminal, error messages are withheld until has completed printing. Options The following options can be used singly or combined in any order: Begin printing with page k (default is 1). Produce k-column output (default is 1). This option should not be used with The options and are assumed for multi-column output. Produce k-column output, same as Print multi-column output across the page. This option is appropriate only with the option. Merge and print all files simultaneously, one per column (overrides the and options). Double space the output. Expand input tabs to character positions k+1, 2xk+1, 3xk+1, etc. If k is 0 or is omitted, default tab settings at every eighth position are assumed. Tab characters in the input are expanded into the appropriate number of spaces. If c (any nondigit character) is given, it is treated as the input tab character (default for c is the tab character). In output, replace white space wherever possible by inserting tabs to character positions k+1, 2xk+1, 3xk+1, etc. If k is 0 or is omitted, default tab settings at every eighth position are assumed. If c (any nondigit character) is given, it is treated as the output tab character (default for c is the tab character). Provide k-digit line numbering (default for k is 5). The number occupies the first k+1 character positions of each column of nor- mal output or each line of output. If c (any nondigit character) is given, it is appended to the line number to separate it from whatever follows (default for c is a tab). Set the width of a line to k character positions (default is 72 for equal-width, multi-column output; no limit otherwise). Width specifications are only effective for multi-columnar output. Offset each line by k character positions (default is 0). The number of character positions per line is the sum of the width and offset. Set the length of a page to k lines (default is 66). If k is less than what is needed for the page header and trailer, the option is in effect; that is, header and trailer lines are suppressed in order to make room for text. Use the next argument as the header to be printed instead of the file name. Pause before beginning each page if the output is directed to a terminal rings the bell at the terminal and waits for a Return). Use form-feed character for new pages (default is to use a sequence of line-feeds). Pause before beginning the first page if the standard output is associated with a terminal. Same as Provided for backwards compatibility. Print no diagnostic reports on failure to open files. Print neither the five-line identifying header nor the five-line trailer normally supplied for each page. Quit printing after the last line of each file without spacing to the end of the page. Separate columns by the single character c instead of by the appropriate number of spaces (default for c is a tab). EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text and the arguments associated with the and options as single-byte and/or multi-byte characters. determines the format and contents of date and time strings. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to See envi- ron(5). International Code Set Support Single-byte and multi-byte character code sets are supported. RETURN VALUE
The returns the following values upon completion: Successful completion. One or more of the input files do not exist or cannot be opened. EXAMPLES
Print and as a double spaced, three column listing headed by ``file list'': Write on expanding tabs to columns 10, 19, 28, 37, ... : Print in default format with nonblank lines numbered down the left side: FILES
SEE ALSO cat(1), lp(1), nl(1), ul(1). STANDARDS CONFORMANCE
pr(1)
All times are GMT -4. The time now is 08:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy