commit 5684aef03233db9b3a111efc9ced704e540a2551 parent 54d81851cc05c6e6e2c5522ec525aa4027201ef8 Author: gearsix <gearsix@tuta.io> Date: Tue, 5 Oct 2021 12:46:51 +0100 added catrm.sh Diffstat:
M | README.md | | | 1 | + |
A | src/catrm.sh | | | 14 | ++++++++++++++ |
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md @@ -46,6 +46,7 @@ Scripts related to string parsing/manipulation ### file management - **backup** cp input files ($1..$n) from `filename` to `filename.bak` +- **catrm** `rm -i` but with the option to cat the file - **shh** - runs binaries ($1..$n) and send stdout to /dev/null (this probably needs a rename) - **flac2mp3** - converts .flac files ($1..$n) to .mp3 files - **cpc** - copy the contents of file $1 into file $2 **WARNING: will overwrite contents of file $2** diff --git a/src/catrm.sh b/src/catrm.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +ync= +for f in $@; do + unset ync + while [ ! $ync ]; do + read -p "read remove '$(readlink -f $f)' [y/n/c]? " -n 1 ync + echo "" + if [ "$ync" == "y" ]; then rm $f + elif [ "$ync" == "c" ]; then cat $f; unset ync + elif [ "$ync" == "n" ]; then continue; + else unset ync; fi + done +done