the_earnest/dotfiles
bashrc, function r: invoke stat and rm separately for each file,
Commit 515e5f66b878 · The Earnest · 2026-11-24 14:29 +0000
bashrc, function r: invoke stat and rm separately for each file, display size before deleting
Comments
No comments yet.
Diff
diff --git a/bashrc b/bashrc
--- a/bashrc
+++ b/bashrc
@@ -194,8 +194,18 @@
}
function r() {
- stat -c "%s %n" "$@"
- rm -vi "$@"
+ local size
+ local sizeh
+ for f in "$@"; do
+ if [[ ! -f "$f" ]]; then
+ echo "r: cannot remove '$f', no such file, skipping"
+ continue
+ fi
+ size=$(stat -c "%s" "$f")
+ sizeh=$(numfmt --to iec "$size")
+ echo -n "$sizeh, "
+ rm -vi "$f"
+ done
}
function safermdir()