Sponsored Content
Top Forums UNIX for Advanced & Expert Users Get the first occurence between two patterns Post 302892227 by rpm120 on Tuesday 11th of March 2014 02:27:10 PM
Old 03-11-2014
Lightbulb Get the first occurence between two patterns

I have an output file which gives me the timely status of a server.

Sample file:

Code:
March 11 2014

21:10,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
21:05,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
21:00,   1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
20:55,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
20:50,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
.
.
.
00:00,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...

March 10 2014

21:10,    11,    22,    33,    44,    55,    66,    77,    88,    99,    xx,    yy,    zz...
21:05,    11,    22,    33,    44,    55,    66,    77,    88,    99,    xx,    yy,    zz...
21:00,    11,    22,    33,    44,    55,    66,    77,    88,    99,    xx,    yy,    zz...
20:55,    11,    22,    33,    44,    55,    66,    77,    88,    99,    xx,    yy,    zz...
20:50,    11,    22,    33,    44,    55,    66,    77,    88,    99,    xx,    yy,    zz...
.
.
.
00:00,    11,    22,    33,    44,    55,    66,    77,    88,    99,    xx,    yy,    zz...

March 09 2014

21:10,    123,    221,    331,    441,    551,    661,    771,    881,    991,    xxx,    yyy,    zzz...
21:05,    123,    221,    331,    441,    551,    661,    771,    881,    991,    xxx,    yyy,    zzz...
21:00,    123,    221,    331,    441,    551,    661,    771,    881,    991,    xxx,    yyy,    zzz...
20:55,    123,    221,    331,    441,    551,    661,    771,    881,    991,    xxx,    yyy,    zzz...
20:50,    123,    221,    331,    441,    551,    661,    771,    881,    991,    xxx,    yyy,    zzz...
.
.
.
00:00,    123,    221,    331,    441,    551,    661,    771,    881,    991,    xxx,    yyy,    zzz...

I need to get the first occurrence or sequence between the two patterns i.e "21:10" & "00:00" (time stamps)


Desired output


Code:
21:10,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
21:05,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
21:00,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
20:55,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
20:50,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...
.
.
.
00:00,    1,    2,    3,    4,    5,    6,    7,    8,    9,    x,    y,    z...

Hope I m clear with the problem statement .... Please help...
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

First Occurence

Hi, This is the format of the file that i have StartDate:10/01/06 EndDate :10/02/06 Cno Ccode 1 10 2 11 StartDate:10/03/06 EndDate :10/04/06 Cno Ccode 2 13 4 12 StartDate:10/01/06 EndDate :10/02/06 (5 Replies)
Discussion started by: kkm_job
5 Replies

2. UNIX for Dummies Questions & Answers

First occurence from grep

Hi , supoose i have a file in which a word is repeated so many times. I just want the firts occurence of that word through grep and it should not go to the next one means get the first occurence and stop there. Suggest me some solutions. Thanks Namish (10 Replies)
Discussion started by: namishtiwari
10 Replies

3. Shell Programming and Scripting

Searching patterns in 1 file and deleting all lines with those patterns in 2nd file

Hi Gurus, I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
Discussion started by: toms
4 Replies

4. Shell Programming and Scripting

How to get line after occurence of sequence of patterns

In the past I needed a help with the problem how to search for pattern after the occurence of another pattern which is described in this thread: https://www.unix.com/shell-programmin...-pattern1.html Now I would need something quite similar, only the pattern which is to be searched must be... (3 Replies)
Discussion started by: sameucho
3 Replies

5. Shell Programming and Scripting

Retrieve lines that match any occurence in a list of patterns

I have two files. The first containing a header and six columns of data. Example file 1: Number SNP ID dbSNP RS ID Chromosome Result_Call Physical Position 787066 SNP_A-8575395 RS6650104 1 NOCALL 564477 786872 SNP_A-8575125 RS10458597 1 AA ... (13 Replies)
Discussion started by: Selftaught
13 Replies

6. Shell Programming and Scripting

sed print between 2 patterns only last occurence

Hi, I have a file, which contains the following log data. I am trying to print fromt he file the following data: I have tried using sed, but I am getting from the first pattern Thanks for your help. (5 Replies)
Discussion started by: sol_nov
5 Replies

7. Shell Programming and Scripting

Print between patterns - first occurence, second occurence etc

I have a file # cat asasas AAAAAA 11 22 33 44 BBBBB NILNILNIL AAAAAA 22 33 44 55 66 77 88 BBBBB NILNILNIL (2 Replies)
Discussion started by: anil510
2 Replies

8. Shell Programming and Scripting

Grab nth occurence in between two patterns using awk or sed

Hi , I have an issue where I want to parse through the output from a file and I want to grab the nth occurrence of text in between two patterns preferably using awk or sed ! TICKET NBR : 1 !GSI : 102 ! 3100.2.112.1 11/06/2013 15:56:29 ! 3100.2.22.3 98 ! 3100.2.134.2... (8 Replies)
Discussion started by: OTNA
8 Replies

9. Shell Programming and Scripting

Find matched patterns and print them with other patterns not the whole line

Hi, I am trying to extract some patterns from a line. The input file is space delimited and i could not use column to get value after "IN" or "OUT" patterns as there could be multiple white spaces before the next digits that i need to print in the output file . I need to print 3 patterns in a... (3 Replies)
Discussion started by: redse171
3 Replies

10. Shell Programming and Scripting

Bash - Find files excluding file patterns and subfolder patterns

Hello. For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Discussion started by: jcdole
2 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy