Sponsored Content
Top Forums Shell Programming and Scripting Match Pattern and print pattern and multiple lines into one line Post 302931152 by tigerhills on Sunday 11th of January 2015 04:33:39 AM
Old 01-11-2015
Sun Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output:

File inputs
------------------------------------------
Code:
Server Host = mike

 id     rl  images   allocated        last updated      density  
           vimages   expiration       last read         <------- STATUS ------->
--------------------------------------------------------------------------------
0000L3  10    161   04/19/2012 17:20  04/28/2012 02:35  hcart3   767701387     1
              161   04/27/2019 02:35  04/27/2012 15:08  FULL

0001L3  10    197   04/19/2012 17:21  04/28/2012 10:53  hcart3   759678237     0
              197   04/27/2019 10:53        N/A         FULL

0002L3  10    145   04/19/2012 17:21  04/29/2012 11:19  hcart3   761213111     0
              144   04/28/2019 11:19        N/A         FULL

0003L3  10    166   04/19/2012 17:21  04/29/2012 03:02  hcart3   764249813     0
              166   04/28/2019 03:02        N/A         FULL

0004L3  10    188   04/19/2012 17:21  04/29/2012 19:44  hcart3   759852744     0
              188   04/28/2019 19:44        N/A         FULL

Server Host = alpha

 id     rl  images   allocated        last updated      density 
           vimages   expiration       last read         <------- STATUS ------->
--------------------------------------------------------------------------------
0030L3  10    327   02/05/2013 21:32  02/07/2013 21:18  hcart3   119479242     1
              327   02/06/2020 20:17  04/23/2013 12:08  FULL

0055L3   8      9   05/29/2014 21:00  05/30/2014 03:20  hcart3    38717803     0
                8   05/30/2015 03:20        N/A         FULL

0072L3  10    853   04/23/2012 16:41  04/26/2012 21:58  hcart3   772844983     0
              853   04/25/2019 20:03        N/A         FULL

Please help to get output below as :

output
----------------------
Code:
mike  id     rl  images   allocated        last updated      density   vimages   expiration       last read         <------- STATUS ------->
mike  0000L3  10    161   04/19/2012 17:20  04/28/2012 02:35  hcart3   767701387     1  161   04/27/2019 02:35  04/27/2012 15:08  FULL

mike 0001L3  10    197   04/19/2012 17:21  04/28/2012 10:53  hcart3   759678237     0   197   04/27/2019 10:53        N/A         FULL

mike 0002L3  10    145   04/19/2012 17:21  04/29/2012 11:19  hcart3   761213111     0  144   04/28/2019 11:19        N/A         FULL

mike 0003L3  10    166   04/19/2012 17:21  04/29/2012 03:02  hcart3   764249813     0 166   04/28/2019 03:02        N/A         FULL

mike 0004L3  10    188   04/19/2012 17:21  04/29/2012 19:44  hcart3   759852744     0  188   04/28/2019 19:44        N/A         FULL

alpha  id     rl  images   allocated        last updated      density   vimages   expiration       last read         <------- STATUS ------->
alpha  0030L3  10    327   02/05/2013 21:32  02/07/2013 21:18  hcart3   119479242     1  327   02/06/2020 20:17  04/23/2013 12:08  FULL

alpha  0055L3   8      9   05/29/2014 21:00  05/30/2014 03:20  hcart3    38717803     0  8   05/30/2015 03:20        N/A         FULL

alpha  0072L3  10    853   04/23/2012 16:41  04/26/2012 21:58  hcart3   772844983     0 853   04/25/2019 20:03        N/A         FULL

Please help to get this done suing PERL program


Moderator's Comments:
Mod Comment Please use cod tags for your data and code next time, thanks

Last edited by vbe; 01-11-2015 at 05:49 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenating multiple lines to one line if match pattern

Hi all, I've been working on a script which I have hit a road block now. I have written a script using sed to extract the below data and pumped into another file: Severity............: MAJORWARNING Summary: System temperature is out of normal range. Severity............: MAJORWARNING... (13 Replies)
Discussion started by: phixsius
13 Replies

2. Shell Programming and Scripting

sed print all lines after pattern match

HiCan someone show me how to print all lines from a file after a line matching a pattern using sed?Thanks (13 Replies)
Discussion started by: steadyonabix
13 Replies

3. Shell Programming and Scripting

Print lines before and after pattern match

I am using Solaris, I want to print 3 lines before pattern match pattern 5 lines after pattern match Pattern is abcd to be searched in a.txt. Looking for the solution in sed/awk/perl. Thanks .. Input File a.txt: ================= 1 2 3 abcd 4 5 6 7 8 (7 Replies)
Discussion started by: manuswami
7 Replies

4. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

5. Shell Programming and Scripting

Print lines that do not match the pattern

I need to print the lines that do not match a pattern. I tried using grep -v and sed -n '/pattern/!p', but both of them are not working as I am passing the pattern as variable and it can be null some times. Example ........ abcd...... .........abcd...... .........abcd......... (4 Replies)
Discussion started by: sunny1234
4 Replies

6. Shell Programming and Scripting

awk print pattern match line and following lines

Data: Pattern Data Data Data Data Data Data Data Data Data ... With awk, how do I print the pattern matching line, then the subsequent lines following the pattern matching line. Varying number of lines following the pattern matching line. (9 Replies)
Discussion started by: dmesserly
9 Replies

7. Shell Programming and Scripting

Print only next pattern in a line after a pattern match

I have 2013-06-11 23:55:14 1Umexd-0004cm-IG <= user@domain.com I need sed/awk operation on this, so that it should print the very next pattern only after the the pattern mach <= ie only print user@domain.com (7 Replies)
Discussion started by: anil510
7 Replies

8. Shell Programming and Scripting

Multiple pattern match and print the output in a single line

I need to match two patterns in a log file and need to get the next line of the one of the pattern (out of two patterns) that is matched, finally need to print these three values in a single line. Sample Log: 2013/06/11 14:29:04 <0999> (725102) Processing batch 02_1231324 2013/06/11... (4 Replies)
Discussion started by: rpm120
4 Replies

9. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

10. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies
All times are GMT -4. The time now is 08:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy