5
1
I have a "tracking" directory containing hardlinks to files/dirs in a second directory ( used for tracking moves/renames). If I delete something in the original folder, no disk space is freed as its hardlink still exists. So I want to clean up this "tracking" directory periodically. Therefore I need to find all files in it, that have a hardlink count of 1.
What is the fastest way to find (and remove) recursively all files with a hardlink count of 1?
I know I can do something like find . -type f -exec ls -l {} \+ | grep -P "^.{11}1"
and then some more piping/regexing, but this is ugly and slow. I am looking for something cleaner and faster.
2Check if your
find
supports-links
option. – Kamil Maciorowski – 2016-08-16T22:21:50.2601@KamilMaciorowski Thanks a lot. I stupidely only greped the manpage for "hard" and thus did not find this option. – imsodin – 2016-08-16T22:23:15.963