Skip to main content
added 12 characters in body
Source Link
Firefly
  • 286
  • 3
  • 10

There is a small problem with the Partner column of the second line, but this awk can serve you as a beginning.

BEGIN {
    FS="::";
    OFS="\t";
    print "PARTNER\tNAME\tSERVICE\tCITY\tMOBILE\tEMAIL"
}
{
    split($2,A,"[:,]");
    if ($3 == " ")
    {
        split($5,B,"[:,]");
    }
    else
    {
        split($4,B,"[:,]");
    }

    split(B[1],C,"mail");
    name=A[2];
    service=A[4];
    city=A[6];
    mobile=A[10];
    email=A[8];
    partner=C[1];
    sub("[(]partner[)]", "",partner);

    print partner"\t"name"\t"service"\t"city"\t"mobile"\t"email;
}

Out:

PARTNER NAME    SERVICE CITY    MOBILE  EMAIL
Flipkart     SINDHUJA    PLUMBER    BANGALORE    9987654434  [email protected] 
The Times of India   HALEN   ELECTRICIAN    CHENNAI  934554434   [email protected] 

You have to run it from the shell(bash,zsh..)shell and save it as whatever.awk

awk -f whatever.awk file

There is a small problem with the Partner column of the second line, but this awk can serve you as a beginning.

BEGIN {
    FS="::";
    OFS="\t";
    print "PARTNER\tNAME\tSERVICE\tCITY\tMOBILE\tEMAIL"
}
{
    split($2,A,"[:,]");
    if ($3 == " ")
    {
        split($5,B,"[:,]");
    }
    else
    {
        split($4,B,"[:,]");
    }

    split(B[1],C,"mail");
    name=A[2];
    service=A[4];
    city=A[6];
    mobile=A[10];
    email=A[8];
    partner=C[1];
    sub("[(]partner[)]", "",partner);

    print partner"\t"name"\t"service"\t"city"\t"mobile"\t"email;
}

Out:

PARTNER NAME    SERVICE CITY    MOBILE  EMAIL
Flipkart     SINDHUJA    PLUMBER    BANGALORE    9987654434  [email protected] 
The Times of India   HALEN   ELECTRICIAN    CHENNAI  934554434   [email protected] 

You have to run it from the shell and save it as whatever.awk

awk -f whatever.awk file

There is a small problem with the Partner column of the second line, but this awk can serve you as a beginning.

BEGIN {
    FS="::";
    OFS="\t";
    print "PARTNER\tNAME\tSERVICE\tCITY\tMOBILE\tEMAIL"
}
{
    split($2,A,"[:,]");
    if ($3 == " ")
    {
        split($5,B,"[:,]");
    }
    else
    {
        split($4,B,"[:,]");
    }

    split(B[1],C,"mail");
    name=A[2];
    service=A[4];
    city=A[6];
    mobile=A[10];
    email=A[8];
    partner=C[1];
    sub("[(]partner[)]", "",partner);

    print partner"\t"name"\t"service"\t"city"\t"mobile"\t"email;
}

Out:

PARTNER NAME    SERVICE CITY    MOBILE  EMAIL
Flipkart     SINDHUJA    PLUMBER    BANGALORE    9987654434  [email protected] 
The Times of India   HALEN   ELECTRICIAN    CHENNAI  934554434   [email protected] 

You have to run it from the (bash,zsh..)shell and save it as whatever.awk

awk -f whatever.awk file

added 43 characters in body
Source Link
Firefly
  • 286
  • 3
  • 10

There is a small problem with the Partner column of the second line, but this awk can serve you as a beginning.

BEGIN {
    FS="::";
    OFS="\t";
    print "PARTNER\tNAME\tSERVICE\tCITY\tMOBILE\tEMAIL"
}
{
    split($2,A,"[:,]");
    if ($3 == " ")
    {
        split($5,B,"[:,]");
    }
    else
    {
        split($4,B,"[:,]");
    }

    split(B[1],C,"[( ]""mail");
    name=A[2];
    service=A[4];
    city=A[6];
    mobile=A[10];
    email=A[8];
    partner=C[1];
    sub("[(]partner[)]", "",partner);

    print partner"\t"name"\t"service"\t"city"\t"mobile"\t"email;
}

Out:

PARTNER NAME    SERVICE CITY    MOBILE  EMAIL
Flipkart     SINDHUJA    PLUMBER    BANGALORE    9987654434  [email protected] 
The Times of India   HALEN   ELECTRICIAN    CHENNAI  934554434   [email protected] 

You have to run it from the shell and save it as whatever.awk

awk -f whatever.awk file

There is a small problem with the Partner column of the second line, but this awk can serve you as a beginning.

BEGIN {
    FS="::";
    OFS="\t";
    print "PARTNER\tNAME\tSERVICE\tCITY\tMOBILE\tEMAIL"
}
{
    split($2,A,"[:,]");
    if ($3 == " ")
    {
        split($5,B,"[:,]");
    }
    else
    {
        split($4,B,"[:,]");
    }

    split(B[1],C,"[( ]");
    name=A[2];
    service=A[4];
    city=A[6];
    mobile=A[10];
    email=A[8];
    partner=C[1];

    print partner"\t"name"\t"service"\t"city"\t"mobile"\t"email;
}

There is a small problem with the Partner column of the second line, but this awk can serve you as a beginning.

BEGIN {
    FS="::";
    OFS="\t";
    print "PARTNER\tNAME\tSERVICE\tCITY\tMOBILE\tEMAIL"
}
{
    split($2,A,"[:,]");
    if ($3 == " ")
    {
        split($5,B,"[:,]");
    }
    else
    {
        split($4,B,"[:,]");
    }

    split(B[1],C,"mail");
    name=A[2];
    service=A[4];
    city=A[6];
    mobile=A[10];
    email=A[8];
    partner=C[1];
    sub("[(]partner[)]", "",partner);

    print partner"\t"name"\t"service"\t"city"\t"mobile"\t"email;
}

Out:

PARTNER NAME    SERVICE CITY    MOBILE  EMAIL
Flipkart     SINDHUJA    PLUMBER    BANGALORE    9987654434  [email protected] 
The Times of India   HALEN   ELECTRICIAN    CHENNAI  934554434   [email protected] 

You have to run it from the shell and save it as whatever.awk

awk -f whatever.awk file

Source Link
Firefly
  • 286
  • 3
  • 10

There is a small problem with the Partner column of the second line, but this awk can serve you as a beginning.

BEGIN {
    FS="::";
    OFS="\t";
    print "PARTNER\tNAME\tSERVICE\tCITY\tMOBILE\tEMAIL"
}
{
    split($2,A,"[:,]");
    if ($3 == " ")
    {
        split($5,B,"[:,]");
    }
    else
    {
        split($4,B,"[:,]");
    }

    split(B[1],C,"[( ]");
    name=A[2];
    service=A[4];
    city=A[6];
    mobile=A[10];
    email=A[8];
    partner=C[1];

    print partner"\t"name"\t"service"\t"city"\t"mobile"\t"email;
}