我有文件的上下文如下:
CA Services Status Report
Component Name Pid Status
------------------------------------ ------- --------------
WAAE Web Server (ASD) 20841 running
WAAE Application Server (ASD) 20281 running
WAAE Scheduler (ASD) 20486 running
WAAE Agent (WA_AGENT) 20109 running
CA-wcc-services Server 22385 running
CA-wcc Server 24410 running
我只想在屏幕上打印Pid。
我尝试使用awk和grep,但无法打印Pid。
cat test | awk '{print $5}'
我只想打印“ Pid”列,但无法完全打印它。
您能否尝试以下内容(已通过提供的示例进行了测试)。
awk 'NF && !/Report/ && !/Status/ && !/^-/{print $(NF-1)}' Input_file
或(根据詹姆士爵士的评论):
awk 'NF&&$(NF-1)~/[0-9]+/{print $(NF-1)}' Input_file
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句