61 lines
1.4 KiB
Bash
Executable File
61 lines
1.4 KiB
Bash
Executable File
#!/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
|