LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-19-2005, 01:26 PM   #1
Crimson Star
LQ Newbie
 
Registered: Jan 2005
Posts: 1

Rep: Reputation: 0
How to Delete?


Is there anyway in Linux to delete wildcard files in multiple subdirectories? Say I'm in DirectoryA which has SubdirectoryA and SubdirectoryB. In each of these subdirectories there are various files. How would I go about deleting, say, all files that start with the letter 'a' without having to issue separate rm -r a* for each subdirectory?
Thanks.
 
Old 01-19-2005, 01:33 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Hi,

Here's one way:

find . -type f -name "a*" -exec ls {} \;

If this wokrs for you change the ls to rm, the ls is there for testing the a*.

See man find and online docs for details of the find command. Do be carefull with the -exec rm command. Test first!!

Hope this helps.

Last edited by druuna; 01-19-2005 at 01:35 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete files that won't delete? di11rod Linux - Security 7 10-19-2005 10:14 PM
can I delete these??? adambeazley Linux - Newbie 8 05-07-2004 05:36 PM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 03:46 AM
Delete zaldyd Linux - Newbie 1 08-07-2003 05:58 AM
how to delete? RRMitsu Linux - General 1 12-26-2002 03:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration