LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-26-2018, 12:21 AM   #1
rajaviknesh
LQ Newbie
 
Registered: Sep 2018
Posts: 1

Rep: Reputation: Disabled
How to merge two rows in a same row from a text file in linux shell script


From Nagios I downloaded its html file by using wget command and then I converted that htmlfile to Textfile by using following code:

html2text -width 180 file.html >a.txt

then I cut the first 10 lines becoz I dont want that text and I got below textfile output

awk 'NR > 10 { print }'a.txt > b.txt

I have to merge two rows into single row not for all lines only for particular output from b.txt file.
Note: the text file contains N number of lines


Here the b.txt File Output:

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 atte
02-08-2018 02:05:2018 Service Alert Critical required

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

Thanks in advance

Last edited by rajaviknesh; 09-26-2018 at 12:43 AM. Reason: Not aligned properly
 
Old 09-26-2018, 12:42 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Your expected output is unreadable. I suggest you put code tags around it (see my signature).
 
Old 09-26-2018, 12:50 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by rajaviknesh View Post
Code:
                             
    01-08-2018 07:05:05   DISK OK - free space:Service Required  Critical    CRITICALservice requiredCPU:loadaverage 6.0%
Are you sure? Where does the lower case service required come from?

From the other lines, I gather that the columns of two subsequent lines should be merged, but the above line breaks this assumption.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to convert words in a text file [columns to rows] naveenchandar Linux - Newbie 2 11-08-2012 01:00 AM
How can I use Shell script to edit row 23 column 5-8 in a txt file? leena_d Linux - Newbie 4 12-14-2009 03:43 AM
Paste each single row from n separate text files into a new file containing n rows Mike_V Programming 11 04-27-2009 11:51 PM
Shell script to parse csv-like output, row by row utahnix Linux - General 8 12-08-2007 05:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration