Skip to the content

nano.cat

Snippets of Mălin Cenușă

  • Home
  • Categories
  • Malware Samples
  • mălin.ro
  • blackhat.pm
  • palma.solutions

Remove all files except specific extension

Date: July 30, 2020
Tags: bash, find, Linux, remove files
Categories: Bash, Linux

To recursively remove all files except those with a specific extension use this:

find . -type f ! -name '*.txt' -delete

Reference: https://unix.stackexchange.com/questions/78376/in-linux-how-to-delete-all-files-except-the-pattern-txt

« Random sleep duration in bash
WordPress memory limit »

Categories



© 2022 nano.cat. All rights reserved. Powered by WordPress.