Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 05-15-2005, 06:49 AM   #1
Senior Member
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Running a command across several directories

Decided this was deffinately a newbie question

I'm trying to remove some particular files from about 4 different directories, but they all start with the same string. Is it possible for me to be in their parent directory and run just one command to delete the files out of all subdirectories?

Meaning instead of "cd /Dir1 ; rm FileX1* ; cd ../Dir2 ; rm FileX1*" et cetera. I happen to do this several times a day for a variety of file names and I'd like to speed up the process.

-- Poetics
Old 05-15-2005, 07:16 AM   #2
Registered: Jan 2003
Location: RaMetal
Distribution: Solaris,FC2,FreeBSD
Posts: 41

Rep: Reputation: 15
cd their parent directory and try this:
find ./ -name "FileX1*" -exec rm -f {} \;

Old 05-15-2005, 07:26 AM   #3
Senior Member
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Original Poster
Rep: Reputation: 49
Thanks a lot! I'll try that out next time I do some cleanup (shouldn't be too long here)


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
[SOLVED] command to list directories only frieza Linux - Software 16 04-01-2016 11:53 AM
How to just list directories using ls command shazam75 Linux - Newbie 10 01-26-2006 02:34 PM
Problems running CGIs from user directories lsgko Linux - Software 0 10-13-2005 10:56 AM
rm command - deleting directories Micro420 Linux - Newbie 11 11-02-2003 02:18 PM
running cgi scripts in other directories init-5 Linux - Software 2 09-16-2003 03:01 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:13 PM.

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