forked from PhilippeR/Pra_Vmaf_Plotting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall_symlinkl.sh
executable file
·34 lines (30 loc) · 1.04 KB
/
uninstall_symlinkl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
main() {
local link_name="plot_vmaf_improved"
local paths=("/usr/local/bin" "/usr/bin" "$HOME/bin" "$HOME/.local/bin")
local found_path=""
local response
# Check each path for the existence of the symlink and prompt for its removal
for path in "${paths[@]}"; do
if [[ -L "$path/$link_name" ]]; then
printf "Found symlink in '%s'. Do you want to remove it? [y/N]: " "$path"
read -r response
if [[ "$response" =~ ^[Yy] ]]; then
if rm "$path/$link_name"; then
printf "Symlink removed successfully from '%s'.\n" "$path"
return 0
else
printf "Failed to remove the symlink from '%s'.\n" "$path" >&2
return 1
fi
fi
found_path="$path"
break
fi
done
if [[ -z "$found_path" ]]; then
printf "No symlink named '%s' found in the checked directories.\n" "$link_name"
return 1
fi
}
main "$@"