Merge branch 'develop' of https://zdv2.bktei.com/gitweb/BK-2020-03 into develop
[BK-2020-03.git] / doc / user / rmsym.org
... / ...
CommitLineData
1* rmsym - Symlink deleter
2#+TITLE: rmsym - Symlink deleter
3#+AUTHOR: Steven Baltakatei Sandoval
4#+DATE:2023-02-20
5#+EMAIL:baltakatei@gmail.com
6#+LANGUAGE: en
7#+OPTIONS: toc:nil
8
9Created by [[https://baltakatei.com][Steven Baltakatei Sandoval]] on
102023-02-20T18:43+00
11under a [[https://creativecommons.org/licenses/by-sa/4.0/][CC BY-SA 4.0]] (🅭🅯🄎4.0) license and last updated on
122023-02-20T18:43+00
13
14** Summary
15~rmsym~ is a Bash script which deletes symbolic links specified by
16positional arguments.
17
18** Versions
19| Version | Description |
20|---------+----------------------------------------------------------------|
21| 0.0.1 | Initial version. Does not accept or pass on arguments to ~rm~. |
22| | |
23
24** Background
25I needed a script that would let me quickly delete only symlinks if I
26were to provide it with a mix of paths of files, directories, or
27symlinks; specifically, I want to be able to create music playlists
28that any music player can parse; most music players can recursively
29scan directories and a directory tree of symlinks would reduce the
30need to maintain multiple copies of music files on the same file
31system. However, in order to assure myself that when I prune symlinks
32that I don't delete actual files targeted by the symlinks, I need a
33program that will only delete symlinks.
34
35Bash supports testing whether a path is a symlink or not via the ~-h~
36test. For example, here is a simple Bash script that will report
37whether a symlink is present at ~$HOME/foo.txt~ or not.
38
39#+begin_example
40#!/bin/bash
41path_myfile="$HOME/foo.txt";
42if [[ -h "$path_myfile" ]]; then
43 echo "STATUS:Is a symlink:$path_myfile";
44else
45 echo "STATUS:Is not a symlink:$path_myfile";
46fi;
47#+end_example
48
49** Reference
50- "Bash Reference Manual", Section: "[[https://www.gnu.org/software/bash/manual/bash.html#Bash-Conditional-Expressions][6.4 Bash Conditional Expressions]]". gnu.org.