Linux - Find and Delete File

PHOTO EMBED

Mon Mar 27 2023 10:00:03 GMT+0000 (Coordinated Universal Time)

Saved by @hardikraja #python

#Approach 1
find . -name "autoencoder_class_*.*" -exec /bin/rm -i {} \;
find . -name "tf_model.h5" -exec /bin/rm -i {} \;

#Approach 2
#1. Display the big files in descending order of size
find . -type f -exec du -h {} + | sort -rh | head -n 20

#2. Delete the files displayed in step 1, one by one
find . -type f -exec du -h {} + | sort -rh | head -n 20 | awk '{print $2}' | xargs -i -p rm '{}'
content_copyCOPY

https://www.cyberciti.biz/faq/linux-unix-how-to-find-and-remove-files/