vim new file

This commit is contained in:
2026-09-21 19:25:52 +03:00
parent e1f9a3b08b
commit a1a711465d
4 changed files with 165 additions and 4 deletions
Executable
+60
View File
@@ -0,0 +1,60 @@
#!/bin/ksh
# Colors
RESET="$(printf '\033[0m')"
BLUE="$(printf '\033[1;34m')"
RED="$(printf '\033[1;31m')"
if [ "$#" -eq 0 ]; then
echo "usage: srm file ..."
exit 1
fi
for file in "$@"; do
if [ ! -e "$file" ]; then
echo "srm: $file: No such file"
continue
fi
if [ -d "$file" ]; then
echo "srm: $file: is a directory"
continue
fi
# --------------------------------------------------------
# Show filename in blue
# --------------------------------------------------------
printf "%s------------------------------------------------------------%s\n" \
"$BLUE" "$RESET"
printf "%sFile: %s%s\n" \
"$BLUE" "$file" "$RESET"
printf "%s------------------------------------------------------------%s\n" \
"$BLUE" "$RESET"
# Show first 10 lines of file
head -n 10 -- "$file"
printf "%s------------------------------------------------------------%s\n" \
"$BLUE" "$RESET"
# --------------------------------------------------------
# Confirmation in red
# --------------------------------------------------------
printf "%sDelete '%s'? [y/N] %s" \
"$RED" "$file" "$RESET"
read answer
case "$answer" in
y|Y|yes|YES)
rm -- "$file"
;;
*)
echo "Not deleted: $file"
;;
esac
done