Relevance to read lines of file between two fixed pattern

(imported topic written by Darknight)

Hi All,

i have created a script which is storing its output into a file . i am trying to read lines of this files appearing in between pattern1 to pattern2 through relevance.

Can you please assit in it.

thanks

(imported comment written by jgstew)

Are pattern1 and pattern2 on the same line?

Like this: (easier)

Line1_stuff

LineX pattern1pattern2

LineN_stuff

Or this: (harder)

Line1_stuff

LineX_pattern1

LineX_pattern2

LineN_stuff

Related stuff:

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014972079

http://support.bigfix.com/inspectors/Filesystem%20Objects_Any.html

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014823886

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014757716

(imported comment written by JasonWalker)

Easiest way I’ve seen is to decide on a pattern (that WON’T appear in the file), concat the lines together using that pattern, and then use “substrings separated by MYTAG of preceding text of following text of …”

Get lines between “tag 1” and “tag 2”:

q:

lines

of

file

“c:\temp\test.txt”

A:
line a

A:
tag 1

A:
line b

A:
line c

A:
line d

A:
tag 2

A:
line e

T:
0.207 ms

I:
plural file line

q:

concatenation

“|||”

of

lines

of

file

“c:\temp\test.txt”

A:
line a|||tag 1|||line b|||line c|||line d|||tag 2|||line e

T:
0.213 ms

I:
singular string

q:

(substrings separated by

“|||”

of

(preceding text

of

first

“tag 2”

of

following text

of

first

“tag 1”

of

concatenation

“|||”

of

(lines

of

it
)))

of

file

“c:\temp\test.txt”

A:

A:
line b

A:
line c

A:
line d

A:

T:
0.256 ms

I:
plural substring

(imported comment written by Darknight)

Hi ,

i have pattern like : 11.1.10,REV=2005.01.21.16.34

so i would like to have only 11.1.10 read from the above line that is relevance should check for pattern REV and should exclude anything appended after REV alongwith word REV.

Please suggest the relevance i have to write to achieve this result…

(imported comment written by jgstew)

preceding text of first “,REV=” of lines whose(it contains “,REV=”) of file ???

(imported comment written by Darknight)

thanks a lot jgstew , it will be greast if you can help me in building relevane which can give output as

gwd.grpinf.net out of the dns-name :

dcn1pclx42a.gwd.grpinf.net

Could you let me know how can we detect the pattern which will identify “.” that is in above example “dcn1pclx42a.” and remove this part and read only the remianing part.

Thanks

(imported comment written by jgstew)

following text of first “.” of “dcn1pclx42a.gwd.grpinf.net

(imported comment written by Darknight)

Thanks a lot jgstew, but in case if first text prior to first dopt is not fix then how can twist this relevance :

following text of first “.” of “dcn1pclx42a.gwd.grpinf.net

maybe something like :

following text of first “.” of “x.gwd.grpinf.net

where x can by any hostname which is variable.

(imported comment written by jgstew)

As long as the host name does not contain a “.” then it will work as is.

following text of first “.” of “???.gwd.grpinf.net”

(imported comment written by Darknight)

thanks a trillion jgstew for your assistsance in the relevance :slight_smile: