Want to format column of a text file

Hi Techies
I have written a script which is collecting the logs of job running on server and let mail me the output.
I want to format column of output, please help.

CCMS_BAU_from_CACHE      RUN
ETL_SUBSITE_TO_SITE_BAU  RUN
GetClient_Prep_Main      RUN
MDM_Client_BAU   RUN
Sweeper  RUN
Staging_To_Reporting     RUNNING
Bridge_BAU       RUN
CMT_CUSTOMER_BAU RUN
CMT_CLIENT_HIERARCHY_BAU RUN
SAP_CUST_NI_CCMS RUN
CLIENT_DUNS_CUST_NI_CCMS RUN

as you can see Job status is not in a Column, I need them in a column
Please help

Thanks
Atul Singh

Can you please show me what output looks like?
don't understand your question.

Cheers,

show us the sample log content.

Input

I need the o/p like this

please help

thanks
Atul Singh

If your distro *NIX version has that utility:

column -t file

Sorry, I am using AIX and in that column command is not installed
Please suggest another solution

thx
Atul Singh

Do you know the max_length of the first column?

yes, Its 25 char

awk '{ printf "%25s%s", $1,$2 }' input_file

try also:

awk '{ printf "%-25s %s\n", $1,$2 }' input
2 Likes

Hi.

The perl code align runs on most systems. For example:

#!/usr/bin/env bash

# @(#) s1       Demonstrate automatic alignment, align.
# See: http://freecode.com/projects/align

# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C align

FILE=${1-data1}

pl " Input data file $FILE:"
cat $FILE

pl " Results:"
align $FILE

exit 0

producing:

$ ./s1

Environment: LC_ALL = , LANG = en_US
(Versions displayed with local utility "version")
aix 7.1.0.0
bash GNU bash 4.2.10
align 1.7.0

-----
 Input data file data1:
CCMS_BAU_from_CACHE      RUN
ETL_SUBSITE_TO_SITE_BAU  RUN
GetClient_Prep_Main      RUN
MDM_Client_BAU   RUN
Sweeper  RUN
Staging_To_Reporting     RUNNING
Bridge_BAU       RUN
CMT_CUSTOMER_BAU RUN
CMT_CLIENT_HIERARCHY_BAU RUN
SAP_CUST_NI_CCMS RUN
CLIENT_DUNS_CUST_NI_CCMS RUN

-----
 Results:
CCMS_BAU_from_CACHE      RUN
ETL_SUBSITE_TO_SITE_BAU  RUN
GetClient_Prep_Main      RUN
MDM_Client_BAU           RUN
Sweeper                  RUN
Staging_To_Reporting     RUNNING
Bridge_BAU               RUN
CMT_CUSTOMER_BAU         RUN
CMT_CLIENT_HIERARCHY_BAU RUN
SAP_CUST_NI_CCMS         RUN
CLIENT_DUNS_CUST_NI_CCMS RUN

See comment in script for download location for align.

Best wishes ... cheers, drl

awk 'sub($1"[ \t]+",sprintf("%25-s",$1))' infile