Hi All,
I have a list of date number (YYYYMMDD) and its own number in a file.
Here is the example
20170320
D100001
D100002
D100003
20170321
D200001
D200002
D200004
D200005
20170322
D200005
D200006
D200007
If I grep a date ie. 20170321, I expecting to get the following list
D200001
D200002
D200004
D200005
Once it found next first integer, it will need to stop from proceeding.
Thanks Ravin and RudiC. However, I feel RudiC provided solution is easier to apply into my requirement as it is more flexible by replace the date with a variable. Ravin, yours is able to run with constant value, do you think it can change it to variable ?
RudiC, could you briefly your command ? Thanks so much for your given valuable solution.
Well, if it finds the search phrase, it set the boolean variable P to 1. P is evaluated, and if TRUE (or 1), the line is printed ( awk default behaviour). Later, if an integer is found ($0+0 casts the line to a number or (roughly speaking) to something different if a non-number ist encountered), P is reset to 0 and printing stops.