File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # vim:ts=4:sts=4:sw=4:et
3
+ #
4
+ # Author: Hari Sekhon
5
+ # Date: 2024-02-28 01:16:44 +0000 (Wed, 28 Feb 2024)
6
+ #
7
+ # https///github.com/HariSekhon/DevOps-Bash-tools
8
+ #
9
+ # License: see accompanying Hari Sekhon LICENSE file
10
+ #
11
+ # If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
12
+ #
13
+ # https://www.linkedin.com/in/HariSekhon
14
+ #
15
+
16
+ set -euo pipefail
17
+ [ -n " ${DEBUG:- } " ] && set -x
18
+ srcdir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
19
+
20
+ # shellcheck disable=SC1090,SC1091
21
+ . " $srcdir /lib/utils.sh"
22
+
23
+ # shellcheck disable=SC2034,SC2154
24
+ usage_description="
25
+ Finds all hardlinks to a given file by searching the mount point for the same inode number of a file
26
+ "
27
+
28
+ # used by usage() in lib/utils.sh
29
+ # shellcheck disable=SC2034
30
+ usage_args=" <filename>"
31
+
32
+ help_usage " $@ "
33
+
34
+ num_args 1 " $@ "
35
+
36
+ filename=" $1 "
37
+
38
+ inode_number=" $( stat -f " %i" " $filename " ) "
39
+
40
+ mount_point=" $( df " $filename " | awk ' {print $NF}' | tail -n 1) "
41
+
42
+ find " $mount_point " -xdev -inum " $inode_number " -print
You can’t perform that action at this time.
0 commit comments