help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] combine


From: Greg Wooledge
Subject: Re: [Help-bash] combine
Date: Thu, 5 Apr 2018 08:42:32 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Apr 04, 2018 at 10:58:06PM +0000, Val Krem wrote:
> Hi all,
> I have two files. The first file has two columns  and the second file has 
> about 15,000 columns and here is two samplesFile1
> ABC1  zc124
> ABC2  zc125
> ABC3  zc126
> ABC4  zc127
> File2 ( has about 15, 000  columns) ABC1  1 0 1 2 1....1
> ABC2  1 1 2 2 2....2
> ABC3  2 2 1 0 1...,0
> 
> I want to merge the two files by the common column   (column 1 in both files) 
> and  get the  following output
> Result
> Zc124 1 0 1 2 1....1
> Zc125 1 1 2 2 2....2
> Zc126 2 2 1 0 1...,0

https://mywiki.wooledge.org/BashProgramming/04

The first file can be read into an associative array that maps
"ABC1" to "Zc124" (you have to perform the capitalization at some
point, so why not now).

Then when you read the second file line-by-line, you simply replace
the first column with its value from the associative array.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]