Creating Report file with 'vlookup' kind of structure in shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating Report file with 'vlookup' kind of structure in shell
# 1  
Old 02-05-2010
Creating Report file with 'vlookup' kind of structure in shell

Hi,
I have some files in the following structure.

File_a.txt

Field_1 Pass
Field_2 Pass
Field_3 Pass

File_b.txt

Field_1 Pass
Field_2 Fail
Field_3 Pass

File_c.txt

Field_1 Fail
Field_2 Pass
Field_3 Pass


I wanted to parse this and get a final report in this format. Here the ‘Field_1..” column does not change in the three files but I do need to search the fields and print out the corresponding Pass/Fail in this report format. How do I do this in shell?

Final_rep.txt
a b c
Field_1 Pass Pass Fail
Field_2 Pass Fail Pass
Field_3 Pass Pass Pass

regards,
Vikas
# 2  
Old 02-05-2010
One way:

Code:
join File_a.txt File_b.txt > tempfile
join tempfile File_c.txt > Final_rep.txt
rm tempfile

# 3  
Old 02-05-2010
may not a good way:
Code:
awk -v c1="$(wc -l < f1)" -v c2="$(wc -l < f2)" -v c3="$(wc -l < f3)" 'NR==FNR{f1[$1]=$2}NR>=(c1+1) && NR<=(c1+c2){f2[$1]=$2}NR>=(c1+c2+1){print $1,f1[$1],f2[$1],$2}' f1 f2 f3

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Vlookup using Ask from specific column shell script

Input file1 frame1,dummy,server1, 00C1C N/A RDF1+TDEV RW 51789 frame1,dummy,server1, 00C1D N/A RDF1+TDEV RW 51789 frame1,dummy,server1, 00C1E N/A RDF1+TDEV RW 51789 frame1,dummy,server1, 00C1F N/A RDF1+TDEV RW 51789 frame1,dummy,server1, 00C20 N/A RDF1+TDEV RW 51789 frame1,dummy,server1,... (10 Replies)
Discussion started by: ranjancom2000
10 Replies

2. Shell Programming and Scripting

Parsing a log file and creating a report script

The log file is huge and lot of information, i would like to parse and make a report . below is the log file looks like: REPORT DATE: Mon Aug 10 04:16:17 CDT 2017 SYSTEN VER: v1.3.0.9 TERMINAL TYPE: prod SYSTEM: nb11cu51 UPTIME: 04:16AM up 182 days 57 mins min MODEL, TYPE, and SN:... (8 Replies)
Discussion started by: amir07
8 Replies

3. Shell Programming and Scripting

Shell Scripting Vlookup

I am developing shell script on Linux OS and I have two files.Data in each file is like : File1 : A B C E F G X Y Z File 2: A C 12 E G 22 X Z 41 I need if first and third column entries ( $1 & $3) of File1 in same row matches with first & second column... (3 Replies)
Discussion started by: suneet17
3 Replies

4. Programming

Dynamically creating structure in C/C++ program

Hi, For one of the project which i am working on i need to write a cpp code such that it will create the structure dynamically instead of reading it from header file. For example we have a program which is reading a binary file according to the structure mentioned in header file. But we... (0 Replies)
Discussion started by: AmbikaValagonda
0 Replies

5. Shell Programming and Scripting

How we can create the master file through shell to show the tree structure of the directory?

Can we create the master file that show the whole tree structure of the directory till a particular folder? Database that contains four sub repository Sybase,sql,oracle,mysql and sql and oracle contains two subrepostories Siebel and plsql and each repositories contains three folders... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

6. Shell Programming and Scripting

help need while creating tree structure

Hi Experts, I have table in mysql like below: 'user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `parent_id` varchar(100) NOT NULL, `member_name` varchar(100) NOT NULL, `city` varchar(100) NOT NULL, `member_id` varchar(100) NOT NULL, `password` varchar(100) NOT... (1 Reply)
Discussion started by: naw_deepak
1 Replies

7. UNIX for Dummies Questions & Answers

Creating a report from csv file.

Hi Gurus, I need your help in transforming the CSV file into some what a report format. My source file looks like below Date,ProdID,TimeID,LevelID 2010-08-31,200,M,1 2010-08-31,201,Q,2 2010-08-31,202,Y,1 2010-08-31,203,M,5 Output required is ... (9 Replies)
Discussion started by: naveen.kuppili
9 Replies

8. Shell Programming and Scripting

Copy a file by creating folder structure in destination as in Souce

Hello, i am having a source directory which consist of multiple sub directories and my destination folder is a empty directory. if try to copy a file source->test->1.txt from source to destination test2 using the commaind. cp source/test/1.txt desti/ It will copy the 1.txt under desti... (1 Reply)
Discussion started by: tsaravanan
1 Replies

9. Shell Programming and Scripting

vlookup in file with string search

Dear All I had two input file mention as below. Now i want to get op form mention file as below. Kindly how i get do it. Is there any thing in unix like vlookup?. FILE 1: BSC1 RXOTRX-48-8 COM MBL RXOTRX-48-9 COM MBL FILE2: RXOTX-48-8 BHOR04C RXOTX-48-9 BHOR04C op:... (2 Replies)
Discussion started by: jaydeep_sadaria
2 Replies

10. Shell Programming and Scripting

Shell script for a writing the directory structure to a file

Hi All, I am new user of shell scripting has come up with a problem. that I have a directory structure like : Home | |--------A | |----trunk | |-------A_0_1/ | | | |-------A_0_2/ | |--------B | ... (6 Replies)
Discussion started by: bhaskar_m
6 Replies
Login or Register to Ask a Question