Integate two reports - bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Integate two reports - bash script
# 1  
Old 01-11-2009
Integate two reports - bash script

I wrote script in bash which generates this report "first.csv":
Quote:
@admin;;
user1;yes;
user2;yes;
user3;yes;
@develop;;
user4;no;
user5;yes;
user6;no;
user7;no;
@progs;;
user8;no;
user9;no;
...
I wrote script in bash which generates this report "second.csv":
Quote:
@admin;path1;12;
user9;path10;1;
@admin;path2;12;
@develop;path3;12;
@develop;path4;1;
@progs;path5;1;
@progs;path6;1;
@progs;path7;1;
@progs;path8;1;
...
I want to integate two reports: "first.csv" and "second.csv".
I want like so that "result.csv":
Quote:
@admin;;path1;12;
user1;yes;path2;12;
user2;yes;;;
user3;yes;;;
@develop;path3;12;
user4;no;path4;1;
user5;yes;;;
user6;no;;;
user7;no;;;
@progs;path5;1;
user8;no;path6;1;
user9;no;path10;1;
;;path7;1;
;;path8;1;
...
Thx
# 2  
Old 01-11-2009
If awk is acceptable (use nawk or /usr/xpg4/bin/awk on Solaris):
Code:
awk -F\; 'END {
  if (n > c) for (i=c; i<=n; i++)
	  print ";;" t[i]
  }
NR == FNR {
  k = $1; sub(/[^;]*; */, "")
  s[k] = s[k] ? s[k] SUBSEP $0: $0
  next
  }
/^@/ && $1 in s { 
  if (n > c) for (i=c; i<=n; i++)
    print ";;" t[i]
  n = split(s[$1], t, SUBSEP)
  c = 0
  }
{ print $0 (t[++c] ? t[c] : ";;") }
  ' second.csv first.csv


Last edited by radoulov; 01-12-2009 at 06:44 AM..
# 3  
Old 01-13-2009
Thank you very much Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ? --- Post updated at 08:39 AM --- in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies

2. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

3. Shell Programming and Scripting

script to get user id reports korn shell

Dear Friends, Can Any one provide me script to generate list of username with the gecos field. (cat /etc/passwd | cut -d: -f1,5) Please note i have to run this command from nim server and i have password less ssh access.(ssh hostname command) and i want a file to be generated on nim... (1 Reply)
Discussion started by: vinodchauhan123
1 Replies

4. AIX

script to get user id reports

Dear Friends, Can Any one provide me script to generate list of username with the gecos field. (cat /etc/passwd | cut -d: -f1,5) Please note i have to run this command from nim server and i have password less ssh access.(ssh hostname command) and i want a file to be generated on nim... (0 Replies)
Discussion started by: vinodchauhan123
0 Replies

5. Shell Programming and Scripting

Script/command to find the common element from 2 reports

please look the scenario (8 Replies)
Discussion started by: dll_fpga
8 Replies

6. Shell Programming and Scripting

Script/command to find the common element from 2 reports

Please see the below reports.... The startpoint will be always same but the endpoint is different ,across various reports and im looking for a search between "clock network delay(propagated)" and "data arrival time" ....to find the element which is common in both reports(reports are seperated... (0 Replies)
Discussion started by: dll_fpga
0 Replies

7. Shell Programming and Scripting

help with a script to have monthly sar reports

Hi I am still learning shell scripting, so for complex stuff, I need help. I would like to have a script that produces sar monthly reports, so that I can produce a graph from it! The idea is to use /var/adm/sa/<dir of sa files>Looking to hear from you. regards (4 Replies)
Discussion started by: fretagi
4 Replies

8. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

9. Shell Programming and Scripting

creating reports using shell schell script

please advise..very urgent. purpose of my script is that it should generate a report by running a sql script which is stored in a directory and pull the information from DB.script shld be in such a way that I just need to pass a parameter and it shld generate the report and store it in a... (1 Reply)
Discussion started by: complicated
1 Replies
Login or Register to Ask a Question