I tried it in awk and got this..Here's the starting text
Code:
1one 2one 3one 4one 5one 6one 7one 8one 9one 10one
1two 2two 3two 4two 5two 6two 7two 8two 9two 10two
1three 2three 3three 4three 5three 6three 7three 8three 9three 10three
1four 2four 3four 4four 5four 6four 7four 8four 9four 10four
1five 2five 3five 4five 5five 6five 7five 8five 9five 10five
1one 2one 3one 4one 5one 6one 7one 8one 9one 10one
1two 2two 3two 4two 5two 6two 7two 8two 9two 10two
1three 2three 3three 4three 5three 6three 7three 8three 9three 10three
1four 2four 3four 4four 5four 6four 7four 8four 9four 10four
1five 2five 3five 4five 5five 6five 7five 8five 9five 10five
1one 2one 3one 4one 5one 6one 7one 8one 9one 10one
1two 2two 3two 4two 5two 6two 7two 8two 9two 10two
1three 2three 3three 4three 5three 6three 7three 8three 9three 10three
1four 2four 3four 4four 5four 6four 7four 8four 9four 10four
1five 2five 3five 4five 5five 6five 7five 8five 9five 10five
Here's what awk produced
Code:
2one 3one 4one 5one 6one 7one 8one 9one 10one
1two 2two 3two 4two 5two 6two 7two 8two 9two 10two
1three 2three 3three 4three 5three 6three 7three 8three 9three 10three
1four
1five2five
2one 3one 4one 5one 6one 7one 8one 9one 10one
1two 2two 3two 4two 5two 6two 7two 8two 9two 10two
1three 2three 3three 4three 5three 6three 7three 8three 9three 10three
1four
1five2five
2one 3one 4one 5one 6one 7one 8one 9one 10one
1two 2two 3two 4two 5two 6two 7two 8two 9two 10two
1three 2three 3three 4three 5three 6three 7three 8three 9three 10three
1four
1five2five
The awk script:
Code:
#! /usr/bin/awk -f
BEGIN {
cline = 0;
}
{
if (++cline == 6)
{
cline = 0;
printf("%s\n", $0);
}
else if (cline == 1)
{
for (i = 2; i <= NF; ++i)
{
if (i == NF)
{
printf("%s\n", $i);
}
else
{
printf("%s ", $i);
}
}
}
else if (cline == 2 || cline == 3)
{
printf("%s\n", $0);
}
else if (cline == 4)
{
printf("%s\n", $1);
}
else if (cline == 5)
{
printf("%s%s\n", $1,$2);
}
}
END {
}
Let me know if this works out..