From a23765e787b59d24f4c4839e61af968c089a4078 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Fri, 14 Oct 2022 20:38:00 +0300 Subject: [PATCH] add(func): func rmt for move file to ~/.trash --- sub/bash/functions | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sub/bash/functions b/sub/bash/functions index c8ec319..1c4176c 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -231,3 +231,26 @@ json() { fi } +_get_full_file_extension() { + local filename + filename=$(basename "$1") + if [ "${filename:0:1}" = "." ]; then + filename="${filename:1}" + fi + echo ${filename#*.} +} + +rmt() { + local filename TRASH + TRASH=~/.trash + + if [ ! -d "$TRASH" ]; then + mkdir "$TRASH" + fi + + for filename in $* + do + mv "$filename" "$TRASH"/"$(basename "$filename")-$(date +%s)" + done +} +