Skip to content

Commit

Permalink
Add script 'List hard links'
Browse files Browse the repository at this point in the history
  • Loading branch information
cfgnunes committed Sep 17, 2024
1 parent 0e0f7e1 commit 19f2bd8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Directories and files/List hard links
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Source the script 'common-functions.sh'.
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
source "$ROOT_DIR/common-functions.sh"

_main() {
local input_files=""
local std_output=""

# Execute initial checks.
_check_dependencies ""
_display_wait_box "2"
input_files=$(_get_files "par_type=all; par_get_pwd=true")

# Run the main process.
std_output=$(find "$input_files" -type f -links +1 -printf "%i %p\n")
std_output=$(_text_sort "$std_output")
std_output=$(awk 'NR==1 {prev=$1} $1!=prev {print "\nHard links:"; prev=$1} {print $0}' <<<"$std_output")

if [[ -n "$std_output" ]]; then
std_output="Hard links:"$'\n'"$std_output"
fi

_display_text_box "$std_output"
}

_main "$@"

0 comments on commit 19f2bd8

Please sign in to comment.