Output allignment

Hi Guys,

I hope you are doing good out there.

I am facing some issues in the alligment of the output of a shell script.

Below is the statement which is formatting the output:

echo  $File | awk -F '[ /]' '{print $13,$15="\t"$16,$4="",$5,$6,$7}' 

and its output is

Domain           Log file                                           Time last updated
ICCIR2TEST16    BPOrderExecutionManagement-Gemini-BPOrderExecutionManagement-Gemini.log  Jul 14 10:59
ICCIR2TEST16    ContactChannelManagement-SVAP-ContactChannelManagement-SVAP.log  Jul 14 10:42
ICCIR2TEST16    DataIntegration-Misc-DataIntegration-Misc.log  Jul 14 10:33
ICCIRSTDEV03    CustomerContactManagement-CRM6-CustomerContactManagement-CRM6.log  Jul 14 10:58
ICCIRSTDEV03    CustomerPersonalInformationManagement-CRM6-CustomerPersonalInformationManagement-CRM6.log  Jul 14 10:55
ICCIRSTDEV03    TIL_SCM_CRM6-TIL_SCM_CRM6.log  Jul 14 12:05

As you can see the last coloumn is not alligned properly. This is due to invariable string size of the files.

I tried lots of tricks but no luck.

Can you please let me know the way to properly allign the output?

Any help would be highly appereciated.

Thanks,
Chandan

use format specifiers %s with width: %30s.

I made up numbers because I don't know what your data looks like. When you need alignment always pick a width that is at least as wide or wider the field can ever be.

awk -F '[ /]' '{printf (%30s% %20s\t%30s %5s= %10s %10s %10s\n",$13,$15,$16,$4,$5,$6,$7) }'  $File
1 Like

Thanks for the help Jim,

Now, the output is alligned properly after making the changes suggested by you. Please see below;

 Domain           Log file                                                                                 Time last updated
ICCIR2Test11     CustomerPersonalInformationManagement-CRM6-1-Process_Archive.log                            Jul 15 07:53
ICCIR2Test13     Top-UpTransactionManagement-PAS-Top-UpTransactionManagement-PAS.log                         Jul 15 07:31
ICCIRSTDEV03     CustomerContractManagement-Gemini-1-CustomerContractManagement-Gemini.log                   Jul 15 08:40
ICCIRSTDEV03     Top-UpTransactionManagement-PAS-2-Top-UpTransactionManagement-PAS.log                       Jul 15 07:31
ICCIRSTDEV03     WarehouseManagement-OOM-WarehouseManagement-OOM.log                                         Jul 15 07:31

Thanks once again for your help.

Chandan