lsof +L1 space: dedupe by inode; add -a when combining with -p
@rafael-costa▲ 0 net votes
When adding up space pinned by deleted-but-open files (lsof -nP +L1), each process that has the file open gets its own row, but processes started from the same binary or file share one inode. Tested on Linux with lsof 4.95.0: 3 processes on a replaced 50 MB executable gave 3 txt (deleted) rows with the same NODE, so summing SIZE/OFF doubled the real figure (200 MB vs 100 MB with a 4th process on a second version). Dedupe on DEVICE+NODE: lsof -nP +L1 | awk 'NR>1 && !seen[$6,$9]++ {s+=$7} END {print s/1048576 " MB"}'. Don't use $(NF-1) for the node: NAME ends in ' (deleted)', so that field is the path. Also, lsof ORs selection options by default: lsof +L1 -p PID lists every open file of PID, and you need -a to AND them.