Sponsored Content
Top Forums Shell Programming and Scripting Merge columns from multiple files Post 302903249 by ali.seifaddini on Monday 26th of May 2014 11:33:20 AM
Old 05-26-2014
Quote:
Originally Posted by RavinderSingh13
Hello,

you can use following, just adding a * to SriniShoo's code.

Code:
 awk 'NR==FNR{a[$2 " " $3]=$6;next} {a[$2 " " $3]=a[$2 " "  $3] OFS $6} END{for(i in a){print i OFS a[i]}}' File*


Output will be as follows.

Code:
3.61696 101.55112 0.000364633 0.000364633 0.000364633
3.62445 101.55112 0.0998519 0.000364633 0.000364633
3.63195 101.54361 0.107302 0.000364633 0.0696797
3.61696 101.54361 0.000364633 0.000364633 0.000364633
3.66192 101.54361 0.0804649 0.000364633 0.115307
3.62445 101.54361 0.0998519 0.000364633 0.000364633
3.63195 101.55112 0.107302 0.000364633 0.0696797



Thanks,
R. Singh
Hello sir

Something is wrong with the script because there are some extra columns and also rows are miss ordered.
I attached sample data for your try.

Thank you so much.
Sample.rar
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

Merge columns of different files

Hi, I have tab limited file 1 and tab limited file 2 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... (10 Replies)
Discussion started by: polsum
10 Replies

4. UNIX for Dummies Questions & Answers

How do I merge multiple columns into one column?

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

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 records based on multiple columns

Hi, I have a file with 16 columns and out of these 16 columns 14 are key columns, 15 th is order column and 16th column is having information. I need to concate the 16th column based on value of 1-14th column as key in order of 15th column. Here are the example file Input File (multiple... (3 Replies)
Discussion started by: Ravi Agrawal
3 Replies

9. UNIX for Beginners Questions & Answers

Merge multiple columns into one using cat

I will like to merge several files using 'cat', but I observe the output is not consistent. the merge begins at the last line of the first file. file1.txt: 1234 1234 1234 file2.txt: aaaa bbbb cccc dddd cat file1.txt file2.txt > file3.txt file3.txt: 1234 1234 1234aaaa bbbb cccc... (13 Replies)
Discussion started by: geomarine
13 Replies

10. Shell Programming and Scripting

Join and merge multiple files with duplicate key and fill void columns

Join and merge multiple files with duplicate key and fill void columns Hi guys, I have many files that I want to merge: file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: (5 Replies)
Discussion started by: yjacknewton
5 Replies
vzubc(8)							    Containers								  vzubc(8)

NAME
vzubc - show User Beancounters in a human-readable format SYNOPSIS
vzubc [option ...] [CTID ...] DESCRIPTION
This utility aims to show current values for User Beancounter in a human-readable format. Values that are in pages are converted into bytes, then long values are converted into kilo-, mega- gigabytes etc. For held and maxheld, it shows how close the values are to the bar- rier and to the limit. Zero and unlimited values are shown as -. One or several CTIDs can be specified to limit the output to the given containers. Each CTID can be either a name or a numeric ID. Note that names can only be used if there is a container on the system with that name (vzlist -o ctid name command is used for name to ID con- version). Unknown CTIDs are ignored. The utility can also be used from inside the container, in this case it only shows the values for that container (and it doesn't make sense to specify CTID argument). OPTIONS
-w, --watch Watch mode: run itself under watch(1), redisplaying the output every 2 seconds (by default) until interrupted by Ctrl-C. -wd Make watch(1) highlight the differences between current and previous output (corresponds to watch -d option). -wn time Refresh interval for watch(1), in seconds (corresponds to watch -n time). -q, --quiet Quiet mode. In this mode, vzubc only shows beancounters with fails and those with held/maxheld values close to limits. -qh ratio Quiet threshold for held to limit ratio. Default is 0.5 (50%). -qm ratio Quiet threshold for maxheld to limit ratio. Default is 0.8 (80%). -r, --relative Relative mode: for fail counters, instead of showing the absolute value, calculate the difference from the previous run. This mode is denoted by a + sign before the FAIL column header. -rd dir Set a directory for saving fail counters to dir (default is /tmp/vzubc.store). -rc Clear all saved fail counter data. -i, --incremental Incremental mode. Shows an additional column with a difference in held value from the previous run. This option also affects quiet mode: all lines with changed held values are shown. Held data is saved to the same directory as fail counter data. -id dir A synonym for -rd. -ic Clear all saved held data. -c, --color Enable color highlighting. Not compatible with --watch. Same thresholds as for quiet mode are used to highlight "more important" lines, plus the lines with non-zero fail counters are highlighted. -f | --file filename Read User Beancounters from filename. By default this is /proc/bc/resources or, if that one is not available, /proc/user_beancoun- ters. Use - to read from standard input. EXAMPLES
vzubc 101 web dns Show all beancounters for CTID 101 and for CTs named web and dns. vzubc -w -wd -wn 10 101 Display beancounters for CT 101 every 10 seconds, highlighting the changes. Interrupt with Control-C. vzubc -q -c Show beancounters with held or maxheld close to limits, plus those with non-zero fail counters, with colors. vzubc -q -qh 0.8 -qm 1 Show beancounters with held value equal to or more than 80% of a limit, and/or with maxheld value equal or more than a limit, plus those with non-zero fail counters. vzubc -w -q -r Display beancounters with held and maxheld close to limits, plus those with increasing fail counters. vzubc -r -q -qh 2 -qm 2 Only show beancounters with increased (since the last run) fail counters. vzubc -rc -ic Show all beancounters, and clear all saved data for relative and incremental mode (i.e. saved values for fail counter and held). FILES
/proc/bc/resources /proc/user_beancounters /tmp/vzubc.store/ubc.* EXIT STATUS
Returns 0 upon successful execution, 1 otherwise. SEE ALSO
watch(1), vzlist(8), vzmemcheck(8), vzcfgvalidate(8), http://wiki.openvz.org/UBC. LICENSE
Copyright (C) 2011, Parallels, Inc. Licensed under GNU GPL. OpenVZ 3 Jun 2011 vzubc(8)
All times are GMT -4. The time now is 04:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy