#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    7
    Rep Power
    0

    Look for two consecutive lines in all text files


    How to get (a list of) all the text files in the current directory and subdirectories which has the following two consecutive lines:
    ctrl_end_date=2009
    ctrl_process=EXPIRED
    OR
    ctrl_end_date=2010
    ctrl_process=EXPIRED

    i.e.
    (ctrl_end_date=2009 OR ctrl_end_date=2010)
    AND
    ctrl_process=EXPIRED
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    7
    Rep Power
    0
    a related question:
    How to get (a list of) all the text files in the current directory and subdirectories which has the following two consecutive lines:
    ctrl_end_date=nnnnnnnn
    ctrl_process=EXPIRED

    where nnnnnnnn is <= 20100902
    e.g.
    nnnnnnnn is a date string
    20070614 and 20100503 meet the criteria
    but 20101102 does not.
  4. #3
  5. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3886
    Firstly, what OS are you using?

    For the second one, are you guaranteed that nnnnnnnn is a valid date string or do you need to check for that too?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    7
    Rep Power
    0
    Originally Posted by ishnid
    Firstly, what OS are you using?

    For the second one, are you guaranteed that nnnnnnnn is a valid date string or do you need to check for that too?
    OS is Windows XP Pro with Cygwin installed:
    CYGWIN_NT-5.1 AH009139 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin
    GNU bash, version 3.2.49(23)-release (i686-pc-cygwin)

    I will assume that nnnnnnnn is a valid date string.
    BTW, is it difficult to check?

IMN logo majestic logo threadwatch logo seochat tools logo