lsof should give all open files for a set of pids

a 夏天 提交于 2019-11-30 11:59:51

The lsof -p option takes a comma-separated list of PIDs. The way you're using xargs will pass the pids as separate arguments leading some to be interpreted as filenames.

Try lsof -p $(your grep | tr '\012' ,) That's going to have a trailing comma, I'm not sure if lsof will care but you could sed it off if necessary.

You can use xargs -L1 lsof -p to run lsof once per pid.

Even better: use lsof -c to list all open files from commands matching a specific pattern:

lsof -c bas # list all processes with commands starting with 'bas'
lsof -c '/ash$/x' # list all commands ending with 'ash' (regexp syntax)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!