Topic
  • 9 replies
  • Latest Post - ‏2014-05-28T09:36:26Z by Darknight
Darknight
Darknight
72 Posts

Pinned topic relevance to read lines of file between two fixed pattern

‏2014-03-28T09:36:19Z |

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

  • jgstew
    jgstew
    410 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-03-28T16:52:15Z  

     

    Are pattern1 and pattern2 on the same line?

     

    Like this:  (easier)

     

    Line1_stuff

    LineX  pattern1<stuffyoucareabout>pattern2

    LineN_stuff

     

    Or this:  (harder)

     

    Line1_stuff

    LineX_pattern1

    <StuffYouCareAbout>

    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

     

     

  • JasonWalker
    JasonWalker
    51 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-04-09T19:18:53Z  

    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

  • Darknight
    Darknight
    72 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-05-15T15:38:44Z  

    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..

  • jgstew
    jgstew
    410 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-05-16T00:52:10Z  
    • Darknight
    • ‏2014-05-15T15:38:44Z

    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..

     

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

  • Darknight
    Darknight
    72 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-05-22T12:02:52Z  
    • jgstew
    • ‏2014-05-16T00:52:10Z

     

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

    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 "<anything>." that is in above example "dcn1pclx42a." and remove this part and read only the remianing part.

     

    Thanks

  • jgstew
    jgstew
    410 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-05-22T18:37:50Z  
    • Darknight
    • ‏2014-05-22T12:02:52Z

    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 "<anything>." that is in above example "dcn1pclx42a." and remove this part and read only the remianing part.

     

    Thanks

     

    following text of first "." of "dcn1pclx42a.gwd.grpinf.net"

     

  • Darknight
    Darknight
    72 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-05-23T09:27:14Z  
    • jgstew
    • ‏2014-05-22T18:37:50Z

     

    following text of first "." of "dcn1pclx42a.gwd.grpinf.net"

     

    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.

  • jgstew
    jgstew
    410 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-05-23T14:00:16Z  
    • Darknight
    • ‏2014-05-23T09:27:14Z

    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.

     

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

    following text of first "." of "?????.gwd.grpinf.net"

     

  • Darknight
    Darknight
    72 Posts

    Re: relevance to read lines of file between two fixed pattern

    ‏2014-05-28T09:36:26Z  
    • jgstew
    • ‏2014-05-23T14:00:16Z

     

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

    following text of first "." of "?????.gwd.grpinf.net"

     

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