ในกรณีที่โปรแกรมหนึ่งมีหลายอินสแตนซ์การรันpidof programจะให้:
`1 2 3`
top -pยอมรับข้อโต้แย้งที่คั่นด้วยเครื่องหมายจุลภาค: 1, 2, 3.
ซึ่งหมายความว่าtop -p `pidof program`จะไม่ทำงาน:
top: unknown argument '1'
usage: top -hv | -bcisSH -d delay -n iterations [-u user | -U user] -p pid [,pid ...]
คุณช่วยแสดงให้ฉันดูวิธีการทำสิ่งนี้ได้ไหม ฉันไม่คุ้นเคยกับ awk, sed, etc ...
top -p $(pgrep -d, "(nginx|mysql)" )