Text Alignment Problem

Dear Friends,

I've one file "sample.log" with the below comma separated lines:

BOND_FORWARD,0 succeeded,0 failed.
EQUITY_FORWARD,0 succeeded,0 failed.
FRA,12 succeeded,0 failed.
OPTION_BAR,16 succeeded,0 failed.
OPTION_VAN,76 succeeded,0 failed.
RENTOPT_CAP_FLOOR,4775 succeeded,0 failed.
RENTOPT_BOP,0 succeeded,0 failed.
RENTOPT_SWP,2159 succeeded,4 failed.
REPO,250 succeeded,0 failed.
SWAP,53903 succeeded,0 failed.
VXHAND,0 succeeded,0 failed.

my intended out put should be, like below:

BOND_FORWARD            0 succeeded             0 failed.
EQUITY_FORWARD          0 succeeded             0 failed.
FRA                     12 succeeded            0 failed.
OPTION_BAR              16 succeeded            0 failed.
OPTION_VAN              76 succeeded            0 failed.
RENTOPT_CAP_FLOOR       4775 succeeded          0 failed.
RENTOPT_BOP             0 succeeded             0 failed.
RENTOPT_SWP             2159 succeeded          4 failed.
REPO                    250 succeeded           0 failed.
SWAP                    53903 succeeded         0 failed.
VXHAND                  0 succeeded             0 failed.

Below are my line of code:

tab_space=$(printf "\t\t";)
sed "s/,/$tab_space/g" sample.log

But the generated output is as below (not properly aligned):

BOND_FORWARD            0 succeeded             0 failed.
EQUITY_FORWARD          0 succeeded             0 failed.
FRA             12 succeeded            0 failed.
OPTION_BAR              16 succeeded            0 failed.
OPTION_VAN              76 succeeded            0 failed.
RENTOPT_CAP_FLOOR               4775 succeeded          0 failed.
RENTOPT_BOP             0 succeeded             0 failed.
RENTOPT_SWP             2159 succeeded          4 failed.
REPO            250 succeeded           0 failed.
SWAP            53903 succeeded         0 failed.
VXHAND          0 succeeded             0 failed.

Any help to correct my code would be much appreciated.
Thanks in advance / Mysore 101 Ganapati.

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

---------- Post updated at 11:46 AM ---------- Previous update was at 11:40 AM ----------

nawk -F, '
{
  for(i=1;i<=NF;i++)
     printf("%-25s%c", $i, (i==NF)?ORS:"")
}' myFile

Hi Vgersh99,

Thanks for opening my eyes,
Thanks for blowing your torch,
Thanks for your time and help,
Thanks for your working answer.
:b:
Cheers~~/ Mysore 101 Ganapati.
A sound discretion is not so much indicated by never making a mistake as by never repeating it.