how to recursively delete *.xtension files from a directory structure
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to recursively delete *.xtension files from a directory structure
Hi,
how can i recursively delete *.xtension files from a directory structure? I cannot find an "rm -r" trick for this? Is there one or do i have to write a script?
All sub-directories in /your/dir will be searched, although note that symbolic links will not be followed. Also only regular files will be deleted, not symbolic links or special files like fifos.
I would be obliged if you could explain the commands you both suggested.
I've the same problem. I stupidly tried
Code:
rm -r /mydir/*.exe
and the whole data got deleted.
I'll try your commands on a test directory and if it solves my problem will execute it on the pen drive with which I'm having problem. (My pendrive is infected with a virus which creates an 'exe' file by the same name as the directory. The more directory you have the more problem.)
The xargs version will be faster, if you have a large number of files to remove. If it's only a few files, it won't make a lot of difference between -exec and xargs variants.
See this post for some background which will help you understand the find / xargs combination.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.