Skip to content

Instantly share code, notes, and snippets.

@arpitr
Created May 16, 2025 10:57
Show Gist options
  • Save arpitr/0c4ff2d007d3a7d243628351d1d5ab07 to your computer and use it in GitHub Desktop.
Save arpitr/0c4ff2d007d3a7d243628351d1d5ab07 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set the log file path
LOG_FILE="lof-file.txt" # Replace with your desired log file path
# Get the current timestamp
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
# Function to log messages with timestamp
log() {
echo "$TIMESTAMP - $1" >> "$LOG_FILE"
}
# Directories to remove
directories=(
"twig-2025-03-17-00-00-04"
)
# Loop through the directories and remove them
for dir in "${directories[@]}"; do
if [ -d "$dir" ]; then
log "Removing directory: $dir"
rm -rf "$dir"
if [ $? -eq 0 ]; then
log "Successfully removed directory: $dir"
else
log "Failed to remove directory: $dir"
fi
else
log "Directory not found: $dir"
fi
done
log "Twig cleanup script completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment