Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想借助lsof有关已打开资源的信息在日志中打印,但我不希望客户看到使用了哪些库。我浏览了 lsof 手册页,但我无法掌握如何从输出中仅排除库。有没有简单的方法来做到这一点?
lsof
您可以使用 sed、awk、cut 来解析 lsof 的输出,只显示那些在其第 4 个字段中没有 Lnn 和 ltx 的行。
您可以使用它的-d标志及其否定字符^从 lsof 的输出中排除内容
例如,以下将阻止lsof 显示txt文件描述符。
lsof -d '^txt'