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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-29-2006, 09:21 PM
|
#1
|
|
Member
Registered: Jul 2005
Distribution: Arch
Posts: 159
Rep:
|
bash command
How do I remove .php, .php4, and .phtml files in a directory and all its subdirectories without removing any of the subdirectories?
So far I know only this:
Code:
rm *.php *.php4 *.phtml
I already tried:
Code:
rm -R *.php *.php4 *.phtml
|
|
|
|
01-29-2006, 09:44 PM
|
#2
|
|
Senior Member
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577
Rep:
|
|
|
|
|
01-29-2006, 09:48 PM
|
#3
|
|
Senior Member
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088
Rep:
|
Try something like:
It will print out the names of all the php files in the current directory and its children. Verify that all the files found you want removing, and then:
Code:
find . -name *.php --execute rm {} \;
I hope this helps
--Ian
|
|
|
|
01-29-2006, 10:20 PM
|
#4
|
|
Member
Registered: Jul 2005
Distribution: Arch
Posts: 159
Original Poster
Rep:
|
Thanks! That worked well Ian!
|
|
|
|
01-30-2006, 04:22 AM
|
#5
|
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515
Rep:
|
With find, you can also combine multiple name-patterns, like this:
find . -name '*.php' -o -name '*.php4' -o -name '*.phtml'
Secondly, I would recommend putting single quotes around your wildcard patterns.
You don't want the shell to replace them by any files it finds in your current directory (filename substitution). Rather, you'll want to pass them unaltered to the "find" command.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:00 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|