From: Steven Baltakatei Sandoval Date: Mon, 20 Feb 2023 18:54:16 +0000 (+0000) Subject: doc(user/rmsym.org):Describe rmsym X-Git-Tag: 0.8.1~3 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/cffa431bc68533d72bea0fd3aaf15e57107ba60f?hp=196c91bb3fb9a469a90f6ed9c0fbf408d14fe040 doc(user/rmsym.org):Describe rmsym --- diff --git a/doc/user/rmsym.org b/doc/user/rmsym.org new file mode 100644 index 0000000..ce939e5 --- /dev/null +++ b/doc/user/rmsym.org @@ -0,0 +1,50 @@ +* rmsym - Symlink deleter +#+TITLE: rmsym - Symlink deleter +#+AUTHOR: Steven Baltakatei Sandoval +#+DATE:2023-02-20 +#+EMAIL:baltakatei@gmail.com +#+LANGUAGE: en +#+OPTIONS: toc:nil + +Created by [[https://baltakatei.com][Steven Baltakatei Sandoval]] on +2023-02-20T18:43+00 +under a [[https://creativecommons.org/licenses/by-sa/4.0/][CC BY-SA 4.0]] (🅭🅯🄎4.0) license and last updated on +2023-02-20T18:43+00 + +** Summary +~rmsym~ is a Bash script which deletes symbolic links specified by +positional arguments. + +** Versions +| Version | Description | +|---------+----------------------------------------------------------------| +| 0.0.1 | Initial version. Does not accept or pass on arguments to ~rm~. | +| | | + +** Background +I needed a script that would let me quickly delete only symlinks if I +were to provide it with a mix of paths of files, directories, or +symlinks; specifically, I want to be able to create music playlists +that any music player can parse; most music players can recursively +scan directories and a directory tree of symlinks would reduce the +need to maintain multiple copies of music files on the same file +system. However, in order to assure myself that when I prune symlinks +that I don't delete actual files targeted by the symlinks, I need a +program that will only delete symlinks. + +Bash supports testing whether a path is a symlink or not via the ~-h~ +test. For example, here is a simple Bash script that will report +whether a symlink is present at ~$HOME/foo.txt~ or not. + +#+begin_example +#!/bin/bash +path_myfile="$HOME/foo.txt"; +if [[ -h "$path_myfile" ]]; then + echo "STATUS:Is a symlink:$path_myfile"; +else + echo "STATUS:Is not a symlink:$path_myfile"; +fi; +#+end_example + +** Reference +- "Bash Reference Manual", Section: "[[https://www.gnu.org/software/bash/manual/bash.html#Bash-Conditional-Expressions][6.4 Bash Conditional Expressions]]". gnu.org.