mercredi 26 septembre 2018

How to join two difrent lines in same line in linux

From Nagios I downloaded its html file by using the command wget, then I converted that html file to text file using following command:

html2text -width 180 file.html >1.txt

Alert Summary Report

                                             Most Recent Alerts                   
                                        08-01-2018 06:11:52 to 08-10-2018 
                                              Duration: 7d 0h 0m 0s
                                                                                    Report Options Summary:

                                                                        Alert Types: Host & Service Alerts
                                                                                State Types: Hard States
                                                                                  Host States: Up, Down, Unreachable
                                                                                 Service States:    Warning, Unknown, Critical

                                   Displaying all 4 matching alerts


                      DISK OK - free space:          CRITICAL
01-08-2018 07:05:05   Service Required     Critical  CPU:loadaverage 6.0%                    

01-08-2018 07:10:25   Service Alert        Critical  memoryUsage

                       DISK OK - free space: 
02-08-2018 01:05:2018  Service Alert       Warning   memoryUsage

                                                      CRITICAl:outstanding alert attention 
02-08-2018 02:05:2018  Service Alert        Critical  required 

After then, I cut the first ten lines using the command:

awk 'NR > 10 { print }'1.txt > 2.txt

Here is the content of file 2.txt:

                      DISK OK - free space:          CRITICAL
01-08-2018 07:05:05   Service Required     Critical  CPU:loadaverage 6.0%                    

01-08-2018 07:10:25   Service Alert        Critical  memoryUsage

                       DISK OK - free space: 
02-08-2018 01:05:2018  Service Alert       Warning   memoryUsage

                                                      CRITICAl:outstanding alert attention 
02-08-2018 02:05:2018  Service Alert        Critical  required 

I would like to merge two rows into a single row not for all the lines, but only for a particular output from the file b.txt.

Note: the text file contains N number of lines

Expected output:

01-08-2018 07:05:05   DISK OK - free space:Service Required  Critical    CRITICALservice requiredCPU:loadaverage 6.0%

01-08-2018 07:10:25   Service Alert                          Critical    memoryUsage

02-08-201801:05:2018  DISK OK - free space:Service Alert     Warning     memoryUsage

02-08-2018 02:05:2018 Service Alert                         Critical     CRITICAL:outstanding alert attention required

Aucun commentaire:

Enregistrer un commentaire