LINUX deleting files except one

Question:

There is a command that deletes all .txt files. How to make it delete .txt files in the same way, except for robots.txt?

find /home/u20806/public_html -maxdepth 1 -mmin +5 -type f -name "*.txt" -delete

Answer:

Like this:

find /home/u20806/public_html \
     -maxdepth 1 \
     -mmin +5 \
     -type f \
     -name "*.txt" \
     ! -name "robots.txt" \
     -delete
Scroll to Top