0

This is the input file with "comma" delimiter.

$ cat dine_final.txt
FILENAME,FILESIZE,FILECOUNT
bur_m2_j12_re_yyyymmdd.dat,1235,1254
bur_m2_j13_re_yyyymmdd.dat,125,12546825
bur_m2_j14_re_yyyymmdd.dat,12565652425,125856
bur_m2_j35_re_yyyymmdd.dat,125,12
bur_m2_j40_re_yyyymmdd.dat,123542,1254
macys_unified_RE_prod_yyyymmdd.dat,12354,1254

I want the output with the good looking format. all the fields under "FILENAME" should start with exact same beginning, "FILESIZE" should start with same field, "FILECOUNT" should start with same field.

FILENAME                                FILESIZE        FILECOUNT
bur_m2_j12_re_yyyymmdd.dat              1235            1254
bur_m2_j13_re_yyyymmdd.dat              125             12546825
bur_m2_j14_re_yyyymmdd.dat              12565652425     125856
bur_m2_j35_re_yyyymmdd.dat              125             12
bur_m2_j40_re_yyyymmdd.dat              123542          1254
macys_unified_RE_prod_yyyymmdd.dat      12354           1254
Philippos
  • 13,453

1 Answers1

1
awk -F, '{printf "%-39s %-15s %-15s\n", $1, $2, $3}' input
  • Tell awk to use commas as the field delimiter
  • print the resulting fields with the specified format

I tried to adjust the field widths to match your output; adjust them as you like. The - between the % and the s says to left-align the field instead of right-align.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255