Individual Line processing in awk

Hi ,

I have a file like

Activate your Membership now!
Dear Cyrus Every relationship needs nurturing. Including ours. 
2011-08-09T10:18:14Z
2011-08-09T10:18:14Z
tag:gmail.google.com,2004:1376659800396305843
T League
email@email.tleague.com
How to refresh a graphical display through bash script
hi i am just testing for the maximum capacity
2011-08-08T21:30:16Z
2011-08-08T21:30:16Z
tag:gmail.google.com,2004:1376611484483384709
me
cyrus.ic@gmail.com
NEWS: 'Write RTI' iPhone Mobile application launched
Dear RTIXT member, We have launched the free iPhone mobile 
2011-08-06T15:08:16Z
2011-08-06T15:08:16Z
tag:gmail.google.com,2004:1376406257464900735
admin@rtixt.org
admin@rtixt.org
[sunfeb2007:1634] Happy Friendship Day!
Hello My Friends, Happy Friendship Day Its fun to make fun of 
2011-08-06T10:23:28Z
2011-08-06T10:23:28Z
tag:gmail.google.com,2004:1376388339345447220
cyrus
cyrus22@gmail.com
OPENING FORC, C++ WITH UNIX AND ORACLE 
For Internal Use of Employer (Please don't delete or 
2011-08-05T09:55:57Z
2011-08-05T09:55:57Z
tag:gmail.google.com,2004:1376296011450947315
Ma Foi Management 
software.jobs@mafoirandstad.com

I want to parse every seven line at a time , where I have to choose only 1,2,6,7 lines to display in some formatted way .
Example for the first 7 lines the output should be like

You have got a mail from T League(email@email.tleague.com)
Sub: Activate your Membership now!
Desc:Dear Cyrus Every relationship needs nurturing. Including ours.

The above format goes for each set of 7 lines , the above example is for first 7 lines only.

Please avoid Perl in answer because I am not aware of that .
If this could be done in awk , as I am not able to find an answer.

Hope I am clear.

Thanks in advance.

Try:

awk '!(NR%7-6){a=$0}!(NR%7-1){b=$0}!(NR%7-2){c=$0}!(NR%7){print "You have got a mail from "a"("$0")\nSub: "b"\nDesc: "c}' file

I don't think awk oneliners should count as oneliners if they're wider than the screen.

how about this:

$ awk '{
        EOF=0;
        for (N=1; (!EOF) && (N<7); N++)
                if(!getline A[N]) EOF=1;

        if(!EOF)
        {
                printf("You have an email from %s (%s)\n", A[5], A[6]);
                printf("Sub: %s\n", $0);
                printf("Desc: %s\n\n", A[1]);
        }
}' < data
You have an email from T League (email@email.tleague.com)
Sub: Activate your Membership now!
Desc: Dear Cyrus Every relationship needs nurturing. Including ours.

You have an email from me (cyrus.ic@gmail.com)
Sub: How to refresh a graphical display through bash script
Desc: hi i am just testing for the maximum capacity

You have an email from admin@rtixt.org (admin@rtixt.org)
Sub: NEWS: 'Write RTI' iPhone Mobile application launched
Desc: Dear RTIXT member, We have launched the free iPhone mobile

You have an email from cyrus (cyrus22@gmail.com)
Sub: [sunfeb2007:1634] Happy Friendship Day!
Desc: Hello My Friends, Happy Friendship Day Its fun to make fun of

You have an email from Ma Foi Management  (software.jobs@mafoirandstad.com)
Sub: OPENING FORC, C++ WITH UNIX AND ORACLE
Desc: For Internal Use of Employer (Please don't delete or

$

It just retrieves 6 extra lines per loop to make up the difference so complex logic to print different lines on different loops isn't needed.

It fits nicely in one line on my 22" LCD :wink: