awk formatted text

Because of debugging, the text needs to be formatted. The
original format is as follows
name active_count event_count wakeup_count expire_count active_since total_time max_time last_change prevent_suspend_time
PowerManagerService.Broadcasts 33 33 1 0 0 4567 254 311709 0
ipc000000ff_Thread-2 0 0 0 0 0 0 0 41124 0
ipc000000fe_Thread-2 0 0 0 0 0 0 0 41121 0
ipc000000fd_Thread-2 1 1 0 0 0 0 0 76434 0
ipc000000f9_ActivityManager 2397 2397 0 0 0 2421 35 312648 0

Requirement, left-aligned with the string in each column of the first row, to facilitate viewing of parameters

cat test1.txt | awk '{printf "%-35s%-20s%-35s%-20s%-35s%-20s%-35s%-20s%-35s%-20s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10}' >test_222.log

The effect is as follows

Guess you like

Origin blog.csdn.net/u010689853/article/details/115012508