find-all-hardlinks.sh 356 B

1234567891011121314151617
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. display_help() {
  4. echo "Usage: ${0##*/} <file>"
  5. exit 2
  6. }
  7. [[ $# -lt 1 ]] && display_help
  8. input="$1"
  9. inode="$(stat -c '%i' "${input}")"
  10. partition="$(df --output=target "${input}" | tail -1)"
  11. echo "All files with inode equal ${inode} on ${partition} partition"
  12. find "$partition" -inum "$inode" -ls 2>/dev/null