因为调试的关系,需要格式化文本
原格式如下
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
要求,与第一行的每列的字符串,左对齐,方便查看参数
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
效果如下