Combine 2 Outputs with a single Checklist


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Combine 2 Outputs with a single Checklist
# 1  
Old 07-14-2015
Combine 2 Outputs with a single Checklist

Checklist
Code:
1.1;  Contains Solaris 
1.2;  Contains Patches
1.3; <no output>
1.3.1; <no output>

Output1
Code:
1.1 Solaris 10 8/07 s10s_u4wos_12b SPARC
1.2 Patch: 127714-03 Obsoletes: Requires: 120011-14 Incompatibles: Packages: SUNWsshcu, SUNWsshdu, SUNWsshu Patch: 128253-01 Obsoletes: Requires: Incompatibles: Packages: SUNWsshcu Patch: 126630-01 Obsoletes: Requires: Incompatibles: Packages: SUNWtcsh
1.3
1.3.1

Output2
Code:
1.1 Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC
1.2 Patch: 125332-24 Obsoletes: Requires: Incompatibles: Packages: SUNWflash-player-plugin Patch: 144962-01 Obsoletes: Requires: Incompatibles: Packages: SUNWgnome-mm-applets-share Patch: 121667-02 Obsoletes: Requires: Incompatibles: Packages: SUNWsfwhea
1.3
1.3.1

Hi there,
I have a checklist with the required output,which I would like it to be formatted and displayed is:
Code:
<html>
<tr><td>1.1<td>Output1: Solaris 10 8/07 s10s_u4wos_12b SPARC;T <br> Output2 : Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC:T</td></tr>

<tr><td>1.2 <td>Output1: Patch: 127714-03 Obsoletes: Requires: 120011-14 Incompatibles: Packages:  SUNWsshcu, SUNWsshdu, SUNWsshu Patch: 128253-01 Obsoletes: Requires:  Incompatibles: Packages: SUNWsshcu Patch: 126630-01 Obsoletes: Requires:  Incompatibles: Packages: SUNWtcsh;T <br> Output2 : Patch: 125332-24 Obsoletes: Requires: Incompatibles: Packages:  SUNWflash-player-plugin Patch: 144962-01 Obsoletes: Requires:  Incompatibles: Packages: SUNWgnome-mm-applets-share Patch: 121667-02  Obsoletes: Requires: Incompatibles: Packages: SUNWsfwhea :T</td></tr>
.....
</tr>

Do advise how it can be done.
# 2  
Old 07-14-2015
Any attempts from your side?
# 3  
Old 07-14-2015
I have did something similar for another project.

Code:
echo -e "2.3 Only enable ftp when necessary"
cat $file | awk '/2.4/ {P=0} /2.3/ {P=1} P' | grep -iq "not installed" && echo T || echo F
echo -e "2.4 Only enable rlogin/rsh/rcp when necessary"
cat $file | awk '/2.5/ {P=0} /2.4/ {P=1} P' | grep -iq 'rlogin.*rsh.*rcp' && echo T || echo F # and condition


Code:
2.3 Only enable ftp when necessary
package vsftpd is not installed
2.4 Only enable rlogin/rsh/rcp when necessary
package rlogin is not installed
package rsh is not installed
package rcp is not installed

Code:
2.3 Only enable ftp when necessary
T
2.4 Only enable rlogin/rsh/rcp when necessary
T

# 4  
Old 07-15-2015
No attempts to solve the actual problem, obviously?

---------- Post updated at 08:48 ---------- Previous update was at 08:46 ----------

Howsoever, try:
Code:
awk '
BEGIN   {print "<html>"}
        {printf "<tr><td>%s<td>%s:", $1, FILENAME
         for (i=2; i<=NF; i++) printf " %s", $i
         printf ";T <br> %s: ", FNM
         getline < FNM
         for (i=2; i<=NF; i++) printf " %s", $i
         printf ":T </td></tr>\n"
        }
' FNM="output2" output1
<html>
<tr><td>1.1<td>output1: Solaris 10 8/07 s10s_u4wos_12b SPARC;T <br> output2:  Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC:T </td></tr>
<tr><td>1.2<td>output1: . . . :T </td></tr>
<tr><td>1.3<td>output1:;T <br> output2: :T </td></tr>
<tr><td>1.3.1<td>output1:;T <br> output2: :T </td></tr>

# 5  
Old 07-15-2015
Hello Alvinoo,

Following may help you in same too.
Code:
 awk 'BEGIN{print "<html>"} FNR==NR{sub(/\;/,X,$1);A[$1];next} ($1 in A){Q=$1;$1="";G[Q]=G[Q]?G[Q] "<br>" FILENAME ":" $0:FILENAME ":" $0;next} END{for(i in G){print VAR1 i  VAR2 G[i] VAR3};print "</html>"}' VAR1="<tr><td>" VAR2="<td>" VAR3="</td></tr>" checklist Output1 Output2

Output will be as follows.
Code:
 <html>
<tr><td>1.1<td>Output1: Solaris 10 8/07 s10s_u4wos_12b SPARC<br>Output2: Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC</td></tr>
<tr><td>1.2<td>Output1: Patch: 127714-03 Obsoletes: Requires: 120011-14 Incompatibles: Packages: SUNWsshcu, SUNWsshdu, SUNWsshu Patch: 128253-01 Obsoletes: Requires: Incompatibles: Packages: SUNWsshcu Patch: 126630-01 Obsoletes: Requires: Incompatibles: Packages: SUNWtcsh<br>Output2: Patch: 125332-24 Obsoletes: Requires: Incompatibles: Packages: SUNWflash-player-plugin Patch: 144962-01 Obsoletes: Requires: Incompatibles: Packages: SUNWgnome-mm-applets-share Patch: 121667-02 Obsoletes: Requires: Incompatibles: Packages: SUNWsfwhea</td></tr>
<tr><td>1.3.1<td>Output1:<br>Output2:</td></tr>
<tr><td>1.3<td>Output1:<br>Output2:</td></tr>
</html>

Hope this helps.

EDIT: Adding a non liner form of solution for same now.
Code:
 awk 'BEGIN      {
   print "<html>"
                } 
     FNR==NR    {
   sub(/\;/,X,$1);
   A[$1];
   next
         } 
     ($1 in A)  {
   Q=$1;
   $1="";
   G[Q]=G[Q]?G[Q] "<br>" FILENAME ":" $0:FILENAME ":" $0;
   next
                } 
     END        {
   for(i in G)
         {
   print VAR1 i  VAR2 G[i] VAR3
                };
   print "</html>"
                }
    ' VAR1="<tr><td>" VAR2="<td>" VAR3="</td></tr>" checklist Output1 Output2

Thanks,
R. Singh

Last edited by RavinderSingh13; 07-15-2015 at 08:50 AM.. Reason: Added a non oneliner form for solution
# 6  
Old 07-27-2015
Works well but not sorted according to order

Code:
1.1; 
1.2;
1.3;
1.3.1;

Code:
<html>
<tr><td>1.3.1<td>MAS0141.txt:<br>MAS0143.txt:</td></tr>
<tr><td>1.1<td>MAS0141.txt: Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC<br>MAS0143.txt: Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC</td></tr>
<tr><td>1.2<td>MAS0141.txt: Patch: 150031-08 Obsoletes: Requires: 120011-14, 127127-11, 137137-09, 139555-08, 141444-09, 142909-17, 144500-19, 147147-26, 150400-02 Incompatibles: Packages: SUNWldomr Patch: 150031-11 Obsoletes: Requires: 120011-14, 127127-11, 137137-09, 139555-08, 141444-09, 142909-17, 144500-19, 147147-26, 150400-02 Incompatibles: Packages: SUNWldomr Patch: 151696-01 Obsoletes: Requires: 120011-14, 127127-11, 137137-09, 142909-17 Incompatibles: Packages: SUNWldomr<br>MAS0143.txt: Patch: 125332-24 Obsoletes: Requires: Incompatibles: Packages: SUNWflash-player-plugin Patch: 144962-01 Obsoletes: Requires: Incompatibles: Packages: SUNWgnome-mm-applets-share Patch: 121667-02 Obsoletes: Requires: Incompatibles: Packages: SUNWsfwhea</td></tr>
<tr><td>1.3<td>MAS0141.txt:<br>MAS0143.txt:</td></tr>
</html>

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Combine multi-row cell into a single line

My CSV file looks similar to this example (the K, L, and M are in the same cell as J but each on a new line within that cell): 1, A, B, C, D 2, E, F, G, H 3, I, J N, O, K L M, 4, P, Q, R, S I would like to have it look like this: 1, A,... (6 Replies)
Discussion started by: Kim Ashby
6 Replies

2. Shell Programming and Scripting

Returning multiple outputs of a single line based on previous repeated lines

Hello, I am trying to return a time multiple times from a file that has varying output just before the time instance, i.e. cat jumped cat jumped cat jumped time = 1.1 cat jumped cat jumped time = 1.2 cat jumped cat jumped time = 1.3 In this case i would like to output a time.txt... (6 Replies)
Discussion started by: ryddner
6 Replies

3. Shell Programming and Scripting

Combine multiple lines into single line

Hi All , I have a file with below data # User@Host: xyz @ # Query_time: t1 Lock_time: t2 Rows_sent: n1 Rows_examined: n2 SET timestamp=1396852200; select count(1) from table; # Time: 140406 23:30:01 # User@Host: abc @ # Query_time: t1 Lock_time: t2 Rows_sent: n1 Rows_examined:... (6 Replies)
Discussion started by: rakesh_411
6 Replies

4. Shell Programming and Scripting

Search Pattern and combine into single file

Hi Experts Please help me out with the following thing: 2 files and want the output file: {No for using FOR loop because I got 22 million lines} Tried that "It processes only 8000 records per hour" I need a faster way out !!! FileA: 9051 9052 9053 9054 9055 9056 9057 9058 9059 ... (5 Replies)
Discussion started by: navkanwal
5 Replies

5. Shell Programming and Scripting

Combine Multiple Files into Single One File One after other

I am trying to combine 4 .dat files into one single Output file Inputs are:- file123.dat, file256.dat, file378.dat & file490 Expected Output:- FileName=file1 {text from file1} EOF {blank line} FileName=file2 {text from file2} EOF {blank line} FileName=file3 {text from file3} EOF... (4 Replies)
Discussion started by: lancesunny
4 Replies

6. Shell Programming and Scripting

how to find first files in a directory and combine them as a single file?

i have below list of files in a directory. /root/admin/files/file1.txt /root/admin/files/file2.txt /root/admin/files/file3.txt /root/admin/files/pattern.txt /root/admin/files/server.txt i need combine the above text files in the below sequence, file1.txt, pattern.txt,server.txt =>... (8 Replies)
Discussion started by: vel4ever
8 Replies

7. Shell Programming and Scripting

Combine in single file

I have 2 files: phone.txt and mobile.txt ex. phone.txt MOBILENO|DISABLE_DATE 919687877754|9/1/2011| 919687877762|9/1/2011| 919687880573|9/1/2011| 919687882658|9/2/2011| Ex. mobile.txt MOBILENO |TIME 919687880573|2011-09-17 12:23:40| 919687882658|2011-10-10 21:15:33|... (4 Replies)
Discussion started by: khingx
4 Replies

8. Shell Programming and Scripting

Combine 2 values into single variable

Hi gurus, I need to manipulate the output of a database query. The output contains 2 fields (asset and serial number) and I'd like to combine them into a single value, seperated by whitespace. the orginal data is in seprate fileds and of the following format: asset serial asset serial etc ... (6 Replies)
Discussion started by: melias
6 Replies

9. Shell Programming and Scripting

Combine multiple lines in single line

This is related to one of my previous post but now with a slight difference: I need the "Updated:" to be in one line as well as the "Information:" on one line as well. These are in multiple lines right now as seen below. These can have 2 or more lines that needs to be in one line. System name:... (8 Replies)
Discussion started by: The One
8 Replies

10. UNIX for Dummies Questions & Answers

Now to merge/combine several filesystems/harddisks to show up as one single?

hi i have a server with 4 harddisks now i want to somehow combine these 4 harddisks to show up to the system as 1 big harddisk, so i can put my web-root into that big virtual partition. can you guys please point me into to the right direction to achieve this? thanks a lot in advance! (2 Replies)
Discussion started by: scarfake
2 Replies
Login or Register to Ask a Question