你可以用cut
它:
cut -d' ' -f3,5- jboss.log
它打印字段3和从5开始直到结束的字段,而字段由空格分隔.
使用awk,它在多行版本中更加冗长和最佳解释:
script.awk
# on every line { # print field 3 printf "%s", $3 # iterate from 5 to number of fields ... for(i=5;i<=NF;i++) # ... and print them printf " %s", $i # print newline at the end printf "\n" }
像这样称呼它:
awk -f script.awk jboss.log