1 * rmsym - Symlink deleter
2 #+TITLE: rmsym - Symlink deleter
3 #+AUTHOR: Steven Baltakatei Sandoval
5 #+EMAIL:baltakatei@gmail.com
9 Created by [[https://baltakatei.com][Steven Baltakatei Sandoval]] on
11 under a [[https://creativecommons.org/licenses/by-sa/4.0/][CC BY-SA 4.0]] (ðŸ…🅯🄎4.0) license and last updated on
15 ~rmsym~ is a Bash script which deletes symbolic links specified by
19 | Version | Description |
20 |---------+----------------------------------------------------------------|
21 | 0.0.1 | Initial version. Does not accept or pass on arguments to ~rm~. |
25 I needed a script that would let me quickly delete only symlinks if I
26 were to provide it with a mix of paths of files, directories, or
27 symlinks; specifically, I want to be able to create music playlists
28 that any music player can parse; most music players can recursively
29 scan directories and a directory tree of symlinks would reduce the
30 need to maintain multiple copies of music files on the same file
31 system. However, in order to assure myself that when I prune symlinks
32 that I don't delete actual files targeted by the symlinks, I need a
33 program that will only delete symlinks.
35 Bash supports testing whether a path is a symlink or not via the ~-h~
36 test. For example, here is a simple Bash script that will report
37 whether a symlink is present at ~$HOME/foo.txt~ or not.
41 path_myfile="$HOME/foo.txt";
42 if [[ -h "$path_myfile" ]]; then
43 echo "STATUS:Is a symlink:$path_myfile";
45 echo "STATUS:Is not a symlink:$path_myfile";
50 - "Bash Reference Manual", Section: "[[https://www.gnu.org/software/bash/manual/bash.html#Bash-Conditional-Expressions][6.4 Bash Conditional Expressions]]". gnu.org.