LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 05-15-2005, 07:49 AM   #1
Poetics
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.

TIA.
-- Poetics
 
Old 05-15-2005, 08:16 AM   #2
siyeclover
Member
 
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 {} \;


siyeclover
 
Old 05-15-2005, 08:26 AM   #3
Poetics
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)
 
  


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


All times are GMT -5. The time now is 12:43 AM.

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