Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Merge two text files (oh no, not again!) Post 302961140 by RudiC on Tuesday 24th of November 2015 11:33:49 AM
Old 11-24-2015
Would this be close?
Code:
awk 'NR==FNR {T[$1]=$5; next} {print $0 T[$1],""}' FS=";" OFS=";" file1 file2
RB-4.762/G10Q M1         04763-010M01R3-01       ;   940800;        0;  3460800;  2744000;
RB-4.762/G10Q M2         04763-010M02R3-01       ;   940800;        0;  1769600;  4020800;
RB-4.762/G10Q M3         04763-010M03R3-01       ;  1881600;        0;  1041600;  2587200;
RB-4.762/G10Q M4         04763-010M04R3-01       ;   470400;        0;  1164800;  3124800;
RB-4.762/G10Q M5         04763-010M05R3-01       ;   470400;        0;  1422400;  1142400;
RB-4.762/G10Q N          04763-010PM0R3-01       ;  2822400;        0;  2721600;  5062400;
RB-4.762/G10Q P1         04763-010P01R3-01       ;  2822400;        0;  2676800;  2900800;
RB-4.762/G10Q P2         04763-010P02R3-01       ;   470400;        0;  1948800;;
RB-4.762/G10Q P3         04763-010P03R3-01       ;        0;        0;   604800;;
RB-4.762/G10Q P4         04763-010P04R3-01       ;   940800;        0;  1097600;;

---------- Post updated at 17:33 ---------- Previous update was at 17:28 ----------

Sorry, overlooked part of the requirement. Better:
Code:
awk 'NR==FNR {P[$1]=$5; T[$1]=$0; next} {print $0 P[$1],""; delete T[$1]} END {for (t in T) print T[t]}' FS=";" OFS=";" file1 file2
RB-4.762/G10Q M1         04763-010M01R3-01       ;   940800;        0;  3460800;  2744000;
RB-4.762/G10Q M2         04763-010M02R3-01       ;   940800;        0;  1769600;  4020800;
RB-4.762/G10Q M3         04763-010M03R3-01       ;  1881600;        0;  1041600;  2587200;
RB-4.762/G10Q M4         04763-010M04R3-01       ;   470400;        0;  1164800;  3124800;
RB-4.762/G10Q M5         04763-010M05R3-01       ;   470400;        0;  1422400;  1142400;
RB-4.762/G10Q N          04763-010PM0R3-01       ;  2822400;        0;  2721600;  5062400;
RB-4.762/G10Q P1         04763-010P01R3-01       ;  2822400;        0;  2676800;  2900800;
RB-4.762/G10Q P2         04763-010P02R3-01       ;   470400;        0;  1948800;;
RB-4.762/G10Q P3         04763-010P03R3-01       ;        0;        0;   604800;;
RB-4.762/G10Q P4         04763-010P04R3-01       ;   940800;        0;  1097600;;
RB-4.762/G10Q P1-R3      04763-010P01R3-01       ;         ;         ;         ;  1176000;
RB-4.762/G10Q N-R3       04763-010PM0R3-01       ;         ;         ;         ;   940800;
RB-4.762/G10Q M3-R3      04763-010M03R3-01       ;         ;         ;         ;   470400;

?
This User Gave Thanks to RudiC For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Is there any non graphical tool that make selective merge between text files?

whitout using awk / sad and so on? (3 Replies)
Discussion started by: umen
3 Replies

2. Shell Programming and Scripting

Merge text files while combining the multiple header/trailer records into one each.

Situation: Our system currently executes a job (COBOL Program) that generates an interface file to be sent to one of our vendors. Because this system processes information for over 100,000 employees/retirees (and growing), we'd like to multi-thread the job into processing-groups in order to... (4 Replies)
Discussion started by: oordonez
4 Replies

3. AIX

merge text files

Hello. Could you please help to know the command to merge multiple text files into one? I am thinking to use: cat f1.txt f2.txt f3.txt > f4.txt Is it okay to use cat command for same purpose - Or could there be any disadvantage in using it? Thank you (4 Replies)
Discussion started by: panchpan
4 Replies

4. Shell Programming and Scripting

Have several text files and want to merge into a single

Hello, I have several files that begin with db. in my directory and I would like to first take it from a specific word starting from $TTL until the end of the contents then do the same all the way down the directory then merge them into one txt file. Is this possible? I am using cygwin with... (4 Replies)
Discussion started by: richsark
4 Replies

5. Shell Programming and Scripting

merge two text files of different size on common index

I have two text files. text file 1: ID filePath col1 col2 col3 1 10584588.mol 269.126 190.958 23.237 2 10584549.mol 281.001 200.889 27.7414 3 10584511.mol 408.824 158.316 29.8561 4 10584499.mol 245.632 153.241 25.2815 5 10584459.mol ... (8 Replies)
Discussion started by: LMHmedchem
8 Replies

6. Shell Programming and Scripting

Merge the multiple text files into one file

Hi All, I am trying to merge all the text files into one file using below snippet cat /home/Temp/Test/Log/*.txt >> all.txt But it seems it is not working. I have multiple files like Output_ServerName1.txt, Output_ServreName2.txt I want to merge each file into one single file and... (6 Replies)
Discussion started by: sharsour
6 Replies

7. Shell Programming and Scripting

Need to merge multiple text files vertically and place comma between fields

Hello expert friends, I'm writing a script to capture stats using sar and stuck up at report generation. I have around 10 files in a directory and need to merge them all vertically based on the time value of first column (output file should have only one time value) and insert comma after... (6 Replies)
Discussion started by: prvnrk
6 Replies

8. Shell Programming and Scripting

Merge and Sort tabular data from different text files

I have 42 text files; each containing up to 34 lines with following structure; file1 H-01 23 H-03 5 H-05 9 H-02 14 . . file2 H-01 17 H-02 43 H-04 7 H-05 8 H-03 7 . . file3 (6 Replies)
Discussion started by: Syeda Sumayya
6 Replies

9. UNIX for Dummies Questions & Answers

Merge two text files by two fields and mixed output

Hello, I'm back again looking for your precious help- This time I need to merge two text files with matching two fields, output only common records with mixed output. Let's look at the example: FILE1 56153;AAA0708;3;TEST1TEST1; 89014;BBB0708;3;TEST2TEST2; 89014;BBB0708;4;TEST3TEST3; ... (7 Replies)
Discussion started by: emare
7 Replies
AGP(4)							   BSD Kernel Interfaces Manual 						    AGP(4)

NAME
agp -- generic interface to the Accelerated Graphics Port (AGP) SYNOPSIS
device agp DESCRIPTION
The agp driver provides uniform, abstract methods for controlling the following devices: Ali: M1541, M1621 and M1671 host to AGP bridges AMD: 751, 761 and 762 host to AGP bridges ATI: RS100, RS200, RS250 and RS300 AGP bridges Intel: i820, i840, i845, i850, and i860 host to AGP bridges Intel: i810, i810-DC100, i810E, i815, 830M, 845G, 845M, 852GM, 852GME, 855GM, 855GME, 865G, 915G and 915GM SVGA controllers Intel: 82443BX, 82443GX, 82443LX, 82815, 82820, 82830, 82840, 82845, 82845G, 82850, 82855, 82855GM, 82860, 82865, 82875P, E7205 and E7505 host to AGP bridges NVIDIA: nForce and nForce2 AGP controllers SiS: 530, 540, 550, 620, 630, 645, 645DX, 648, 650, 651, 655, 661, 730, 735, 740, 741, 745, 746, 760 and 5591 host to AGP bridges VIA: 3296, 82C597, 82C598, 82C691, 82C694X, 82C8363, 8235, 8237, 8361, 8367, 8371, 8377, 8501, 8601, 862x, 8633, 8653, 8703, 8753, 8754, 8763, 8783, KT880, PM800, PM880, PN800, PN880, PT880, XM266 and XN266 host to PCI bridges The most common application of agp is for running X(7) on the Intel i81x controllers. IOCTLS
The following ioctl(2) operations can be performed on /dev/agpgart, which are defined in <sys/agpio.h>: AGPIOC_INFO Returns state of the agp system. The result is a pointer to the following structure: typedef struct _agp_info { agp_version version; /* version of the driver */ uint32_t bridge_id; /* bridge vendor/device */ uint32_t agp_mode; /* mode info of bridge */ off_t aper_base; /* base of aperture */ size_t aper_size; /* size of aperture */ size_t pg_total; /* max pages (swap + system) */ size_t pg_system; /* max pages (system) */ size_t pg_used; /* current pages used */ } agp_info; AGPIOC_ACQUIRE Acquire control of the AGP chipset for use by this client. Returns EBUSY if the AGP chipset is already acquired by another client. AGPIOC_RELEASE Release control of the AGP chipset. This does not unbind or free any allocated memory, which is the responsibility of the client to handle if necessary. AGPIOC_SETUP Enable the AGP hardware with the relevant mode. This ioctl(2) takes the following structure: typedef struct _agp_setup { uint32_t agp_mode; /* mode info of bridge */ } agp_setup; The mode bits are defined in <sys/agpio.h>. AGPIOC_ALLOCATE Allocate physical memory suitable for mapping into the AGP aperture. This ioctl(2) takes the following structure: typedef struct _agp_allocate { int key; /* tag of allocation */ size_t pg_count; /* number of pages */ uint32_t type; /* 0 == normal, other devspec */ uint32_t physical; /* device specific (some devices * need a phys address of the * actual page behind the gatt * table) */ } agp_allocate; Returns a handle to the allocated memory. AGPIOC_DEALLOCATE Free the previously allocated memory associated with the handle passed. AGPIOC_BIND Bind the allocated memory at given offset with the AGP aperture. Returns EINVAL if the memory is already bound or the offset is not at AGP page boundary. This ioctl(2) takes the following structure: typedef struct _agp_bind { int key; /* tag of allocation */ off_t pg_start; /* starting page to populate */ } agp_bind; The tag of allocation is the handle returned by AGPIOC_ALLOCATE. AGPIOC_UNBIND Unbind memory from the AGP aperture. Returns EINVAL if the memory is not bound. This ioctl(2) takes the following structure: typedef struct _agp_unbind { int key; /* tag of allocation */ uint32_t priority; /* priority for paging out */ } agp_unbind; FILES
/dev/agpgart AGP device node. SEE ALSO
X(7) (ports/x11/xorg) HISTORY
The agp driver first appeared in FreeBSD 4.1. BSD
November 28, 2007 BSD
All times are GMT -4. The time now is 01:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy