-
-
Save jorgemanrubia/3f6c0706a8fb22f3f66d53ac2dbca3ae to your computer and use it in GitHub Desktop.
ChatGPT prompt 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set the directory path where the folders are located | |
dir_path="/path/to/directory" | |
# Get a list of all the folders in the directory | |
folders=($(ls -t $dir_path)) | |
# Delete all folders except the most recent 10 | |
for ((i=10; i<${#folders[@]}; i++)); do | |
rm -r "$dir_path/${folders[i]}" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash script to delete all the folders in a directory but the most recent 10 ones in MacOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment