服务器上运行了多个 was server,要查全部 server 的进程 ID及 server name,不要中间一大段命令参数
- ps -ef | grep java | awk '{print $2,$NF}'
:split
-------------------------------------------------------------------
awk 变量: 来源 AIX 5.3 man
$0 recode, $1 $2 ~= split var
NF NR 在不同的段落下意义不同。
NF
The number of fields in the current record, with a limit of 99. Inside a BEGIN action, the NF special variable is undefined unless a getline function without a Variable parameter has been issued previously.
Inside an END action, the NF special variable retains the value it had for the last recordread, unless a subsequent, redirected, getline function without a Variable parameter is issued prior to entering the END action.
NR
The number of the current input record. Inside a BEGIN action the value of the NR special variable is 0 (zero).
Inside an END action, the value is the number of the last record processed.- echo ab cd 12 34 | awk '{print $NR, $NF}'
结果是 ab 34
单行命令是 END action
:end
阅读(910) | 评论(0) | 转发(0) |