Q:

Getting specific part of output in Linux

I have an output from a shell script like this:
aaa.sh output
     Tue Mar 04 01:00:53 2014
     Time drift detected. Please check VKTM trace file for more details.
     Tue Mar 04 07:21:52 2014
     Time drift detected. Please check VKTM trace file for more details.
     Tue Mar 04 13:17:16 2014
     Time drift detected. Please check VKTM trace file for more details.
     Tue Mar 04 16:56:01 2014
     SQL> ALTER DISKGROUP fra  ADD DISK  '/dev/rhdisk20' 
     Wed Mar 05 00:03:42 2014
     Time drift detected. Please check VKTM trace file for more details.
     Wed Mar 05 04:13:39 2014
     Time drift detected. Please check VKTM trace file for more details.
     Tue Mar 05 05:56:07 2014
     GMON querying group 3 at 10 for pid 18, osid 27590856
     GMON querying group 3 at 11 for pid 18, osid 27590856

I need to get the part, beginning from today's date:
     Wed Mar 05 00:03:42 2014
     Time drift detected. Please check VKTM trace file for more details.
     Wed Mar 05 04:13:39 2014
     Time drift detected. Please check VKTM trace file for more details.
     Tue Mar 05 05:56:07 2014
     GMON querying group 3 at 10 for pid 18, osid 27590856
     GMON querying group 3 at 11 for pid 18, osid 27590856

A:

You can get the date in the correct format like this:
today=$(date +'%a %b %d')

and then search for it like this:
grep "$today" aaa.sh

If there are lines from today without a date, such as your GMON lines, you could add -A to say how many lines after the match you want and use a big number:
grep -A 999999 "$today" aaa.sh

If you are on AIX and there is no -A option, use sed like this:
today=$(date +'%a %b %d')
sed -n "/${today}/,$ p" aaa.sh

Explanation:
That says store today's date in the variable today in the format "Wed Mar 05". Then search, without printing anything (-n) till you find that date, From that point on, till the end of file ($) print all lines (p).

