Untitled
unknown
plain_text
8 days ago
603 B
5
Indexable
#!/bin/bash TARGET_DIR="test_temp_dir" if [ ! -d "$TARGET_DIR" ]; then echo "Error: Directory '$TARGET_DIR' does not exist." exit 1 fi TMP_FILES=("$TARGET_DIR"/*.tmp) if [ ! -e "${TMP_FILES[0]}" ]; then echo "No .tmp files found in '$TARGET_DIR'." exit 0 fi echo "The following .tmp files will be deleted:" ls -l "$TARGET_DIR"/*.tmp echo "Do you want to delete these files? (yes/no):" read user_input if [[ "$user_input" == "yes" ]]; then sudo rm -v "$TARGET_DIR"/*.tmp echo "Temporary files deleted successfully." else echo "Operation canceled. No files were deleted." fi
Editor is loading...
Leave a Comment