I want to delete all hardlinks for a specific file.
The usage would be script somefile, this would count the hardlinks for the file somefile, then it's going to delete all hardlinks keeping this file only.
The command
find / -samefile file-name | xargs rm
will do the needed but this deletes the original file also.
Also you can use
find / -inum Inode-number | xargs rm
But this also would delete the original file.
My first script veriosn looks like
#!/bin/bash
file=$1
inode=`ls -li $file | cut -d" " -f1`
find / -inum $inode | xargs rm
But as I said above this would delete the original file also, so how to keep the first instance and remove others.