Sponsored Content
Top Forums Shell Programming and Scripting Logfile - extracting certain lines to concatenate into 1 line Post 302298543 by daptal on Tuesday 17th of March 2009 11:34:00 PM
Old 03-18-2009
#!/usr/bin/perl -w

use strict;

open (FH,'txt');
my $fb=0;
my @str ;
while (my $line = <FH>){
chomp ($line);
if ($line =~ m/Diags begin/){
$fb =1;
}
if ($fb && !($line =~ m/Diags begin/ || $line =~ m/Diags end/ )){
push @str , $line;
}
if ($line =~ m/Diags end/){
my $x = join " ", @str;
print "$x\n";
@str=();
$fb=0;
}
}

Try this

Cheers

Last edited by daptal; 03-18-2009 at 12:36 AM.. Reason: output
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting Logfile Entries

Hello All, I am trying to write a KSH script that would extract lines from a logfile, within a certain timeframe, in reverse order. Ex. -Sample logfile- INFO 2006-07-12 00:23:00 - ModeDecision Time in WF:27 INFO 2006-07-12 00:24:00 - NRT_MQ_RES:108 INFO 2006-07-12 00:25:00 - getRecords()... (2 Replies)
Discussion started by: harpdl
2 Replies

2. UNIX for Advanced & Expert Users

Need solution concatenate and display 2 lines as 1 with a condition for 2 line ?

I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line. 2 lines from log: 2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (1 Reply)
Discussion started by: vithala
1 Replies

3. Shell Programming and Scripting

concatenate and display 2 lines as 1 with a condition for 2 line ?

I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line. 2 lines from log: 2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (7 Replies)
Discussion started by: vithala
7 Replies

4. UNIX for Advanced & Expert Users

need to concatenate two lines if the line doesnt end with quotes

Hi I am getting a source file where the columns are seperated by comma and double Quotes Eg1 : "AAA","BBB","CCCC" in the same source file i am also getting few lines where my last columns double quotes are ending in its next line or the next next line Eg2: "AAA","BBB","CCC CC"... (9 Replies)
Discussion started by: laxmi131
9 Replies

5. Shell Programming and Scripting

sed / awk to concatenate lines until blank line

Sample input (line feed indicated by ) --------------- The red fox jumped over the brown fence of the red hous He then went into the orchard --------------- Desired Output --------------- The red fox jumped over the brown fence of the red house He then went into the orchard (11 Replies)
Discussion started by: dunstonrocks
11 Replies

6. Shell Programming and Scripting

Extracting line matching a phrase and then the next lines after it

Hi all, I was wondering if someone could tell me a way to extract from a file lines where you search for a phrase and then also extract the next X lines after it (i.e. take a block of text from the file)? Example { id=123 time=10:00:00 date=12/12/09 { ........ ... (6 Replies)
Discussion started by: muay_tb
6 Replies

7. Shell Programming and Scripting

extracting data froma logfile

You are given a 1 year logfile with each line starting with a date in the form “YYYY-MM-DD”. How would you extract logs from the 4th day of each month and put them into a new file (3 Replies)
Discussion started by: DOkuwa
3 Replies

8. Shell Programming and Scripting

Extracting lines after nth LINE from an output

Hi all, Here is my problem for which i am breaking my head for past three days.. I have parted command output as follows.. Model: ATA WDC WD5000AAKS-0 (scsi) Disk /dev/sdb: 500GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type ... (3 Replies)
Discussion started by: selvarajvs
3 Replies

9. UNIX for Dummies Questions & Answers

Extracting the two lines where the first line is matched

Hi, If I have a file of something like @hg19_gold_AL122127.6-131160 GCTTCATCATGCATGGATAGGCTGGCGCCTTTCCTGAGGCCATATGCCGATGGATATG @hg19_gold_AL122127.6-131159 CTTTAATATTTCCGCCACCATCCTGAGTGAATCCCAGCAAGGACAGTCTTTGGGGATT @hg19_gold_AL122127.6-131158... (4 Replies)
Discussion started by: jyu429
4 Replies

10. UNIX for Beginners Questions & Answers

Search for word in huge logfile and need to continue to print few lines from that line til find date

Guys i need an idea for one logic..in shell scripting am struggling with a logic...So the thing is... i need to search for a word in a huge log file and i need to continue to print few more lines from that line and the consecutive line has to end when it finds the line with date..because i know... (1 Reply)
Discussion started by: Prathi
1 Replies
curs_inwstr(3X) 														   curs_inwstr(3X)

NAME
inwstr, innwstr, winwstr, winnwstr, mvinwstr, mvinnwstr, mvwinwstr, mvwinnwstr - get a string of wchar_t characters from a curses window SYNOPSIS
#include <curses.h> int inwstr(wchar_t *str); int innwstr(wchar_t *str, int n); int winwstr(WINDOW *win, wchar_t *str); int winnwstr(WINDOW *win, wchar_t *str, int n); int mvinwstr(int y, int x, wchar_t *str); int mvinnwstr(int y, int x, wchar_t *str, int n); int mvwinwstr(WINDOW *win, int y, int x, wchar_t *str); int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *str, int n); DESCRIPTION
These routines return a string of wchar_t characters in wstr, extracted starting at the current cursor position in the named window. Attributes are stripped from the characters. The four functions with n as the last argument return a leading substring at most n bytes long (exclusive of the trailing NUL). Transfer stops at the end of the current line, or when n bytes have been stored at the location ref- erenced by wstr. If the size n is not large enough to store a complete character, an error is generated. NOTES
Note that all routines except winnwstr may be macros. RETURN VALUES
All routines return ERR upon failure. Upon successful completion, the *inwstr routines return OK, and the *innwstr routines return the num- ber of characters read into the string. SEE ALSO
curses(3X), curs_instr(3X), curs_in_wchstr(3X) curs_inwstr(3X)
All times are GMT -4. The time now is 03:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy