12345678910111213141516171819202122232425262728 |
- #!/bin/bash
- set -e
- if [ $UID -ne 0 ]; then
- echo "请用root用户运行当前脚本 (su root)" && exit 1
- fi
- base_dir=$(
- cd "$(dirname "$0")"
- pwd
- )
- cd $base_dir
- if [[ -z $base_dir ]]; then
- echo "base_dir is empty, exit"
- exit 1
- fi
- log_path="$base_dir/log/**"
- read -p "Are you sure you want to remove all log files? (y/n): " confirm
- if [[ $confirm == [yY] ]]; then
- rm -rf $log_path
- echo "All log files have been removed."
- else
- echo "Operation cancelled."
- fi
|