New to the forum and somewhat of a Bash newbie so go easy.
I have some data in a tsv file, a sample of which looks like this (ignore what look like duplicates, in reality there are many more columns of data):
I would like to use the value in the first column and search a second file such that if that value is present in any line of the second file it is added to the same line in the first file as as a new column. A sample line from the second file looks like this (| delimited):
As you can see the first file can have more than one value in the first column so I would need an OR based search. I know EGREP with | can do this. I can also print the lines in the first file using AWK but I've got no idea how to do this line by line or how to use these as inputs in EGREP such that it will search the second file. I'm also a bit unsure as to how to add the data from the second file to the first.
I hope it's clear but here's my desired output based on my two samples above:
Thanks in advance,
Matt
Last edited by bartus11; 06-09-2014 at 02:16 PM..
Reason: Please use [code][/code] tags.
The awk below produces an output with the original header and only the matching lines (which is good), but the output where the original line numbering in the match found on is used. I can not figure out how to sequentially number the output instead of using the original.
I did try to add... (2 Replies)
Hi
I have a file profile.txt with the below input:
{"atgUserId":"736f14c4-eda2-4531-9d40-9de4d6d1fb0f","firstName":"donna","lastName":"biehler","email":"schoolathome42@live.com","receiveEmail":"y
es"},
{"atgUserId":"c3716baf-9bf8-42da-8a44-a13fff68d20f","firstName":"Gilberto... (6 Replies)
I have a file of 100,000 lines in the below format:
answer.bed
chr1 957570 957852
NOC2L
chr1 976034 976270
PERM1
chr1 976542 976787
PERM1
I need to get each on one line and so far what I have tried doesn't seem to be working. Thank you... (3 Replies)
Sed command to replace a line in a file using line number from the output of a pipe.
Is it possible to replace a whole line piped from someother command into a file at paritcular line...
here is some basic execution flow..
the line number is 412
lineNo=412
Now i have a line... (1 Reply)
Using ksh on AIX what I am trying to do is to read the ls -l output from a file in a do while loop line by line. Extract the user name(3rd field) and the directory/file name(9th field) using awk and save them into variables. su -c to the user and change directory/file permisions to 777. Script I... (13 Replies)
I have this code
echo $logfile | awk ' {arr++; next} END { for (i in arr) {print i} }'
that gives me this output
result1
result2
result3
I try to figure out how to get it like this
result1 result2 result3 (4 Replies)
Hi,
Need awk help to group and print lines to format the output as shown below
INPUT FORMAT
set echo on
set heading on
set spool on
/* SCHEMA1 */ CREATE TABLE T1;
/* SCHEMA1 */ CREATE TABLE T2;
/* SCHEMA1 */ CREATE TABLE T3;
/* SCHEMA1 */ CREATE TABLE T4;
/* SCHEMA1 */ CREATE TABLE T5;... (5 Replies)